Inserting a row then col sum for group

Eric Kelcher

Board Regular
Joined
May 11, 2006
Messages
130
I had this working in another file but would like to make it universal available macro in my Personal program.
I need the file to compare cells in col C(3) then if they are different insert a row with col C(3) saying total then perform a sum function for Col D(4) for that group.
This is the macro I have working in a stand alone program, but I am getting error with "Cells" and generally gotten myself all twisted up with all the definitions I had running in that program, I thought Cells was a macro defined term??

Could someone help either with a new way to do this or get help me with correcting my error(s)?


i = 2
While Not IsEmpty(.Cells(i, 1))
If .Cells(i, 3) <> .Cells(i - 1, 3) Then
.Cells(i, 3).EntireRow.Insert
.Cells(i, 3) = "Total"
.Cells(i, 4).Formula = "=sum(D" & FormStart & ":D" & i - 1 & ")"
 
Last edited:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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