Grand Total Macro

Jimmmy

New Member
Joined
Nov 29, 2010
Messages
25
Hey guys, I need your help again please. I need a macro that adds the rows of data in an array which contains the text "Total" in column A, and inputs those values two lines after the last row in the array; however, it's important to note that there are multiple blank lines in this. I need the macro to disregard those and enter the grand total two lines after the last-used row.

Simply put, I need a sum function from column B to that last used column, and add only those lines that contain the text "Total" in column A, and again, I need this row to be entered two rows after the most-bottom row.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
try:
Code:
Sub insertTotal()
    ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Offset(2).FormulaR1C1 = "=SUMIF(R1C1:R[-1]C1,""total"",R1C:R[-1]C)"
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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