Macro to insert rows

snowhunter

New Member
Joined
Sep 12, 2008
Messages
7
Hi all,
I have been trying to figgue out how to build a Macro that will insert two rows after a column called work center. Every time the work center changes from 1 to 2 or 2 to 3, a macro that can insert two blank rows after and add a subtotal in the total pounds field. For example:
A | B | G H I JKLMNO
Shift | Item | Job |Work Center|Total Pounds
a4 | abc | 123 | 1 | 54
a4 | bca | 213 | 1 | 26
a4 | abc | 123 | 2 | 43
a4 | bca | 213 | 2 | 66

would become:

Shift | Item | Job |Work Center|Total Pounds
a4 | abc | 123 | 1 | 54
a4 | bca | 213 | 1 | 26
80

a4 | abc | 123 | 2 | 43
a4 | bca | 213 | 2 | 66
|109

I hope this terrible layout comes across in the post, if not I will repost using another method. Perhaps two seperate macros? One for inserting rows after work center change and one to add subtotal of column H.
Thanks!
Chris
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try the subtotals function from Data - Subtotals.
At each change in: Select Work Center
Use Function: Select Sum
Add subtotal to: Select - Total Pounds.

See below

Excel Workbook
ABCDE
1ShiftItemJobWork CenterTotal Pounds
2a4abc123154
3a4bca213126
4a4abc123243
5a4bca213266
Original Data
Excel Workbook
ABCDE
1ShiftItemJobWork CenterTotal Pounds
2a4abc123154
3a4bca213126
41 Total80
5a4abc123243
6a4bca213266
72 Total109
8Grand Total189
After Subtotals
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,881
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top