Looking for VBA code to find last row then sum

qfalker

New Member
Joined
Oct 2, 2012
Messages
7
I have no idea where to start - i have searched the board and thought i may have found a pseudo solution but to no avail.

This info may or may not be pertinent but I have 15 sheets - "Sheet1" I have set the Last Row as:
Sub filtertests()
Dim LastRow As Long

'Find the last row
LastRow = Range("A5").CurrentRegion.Rows.Count

I have 9 of the other sheets (named "sheet2" through "sheet10") that have variations of 100 to 5000 rows, in which i need to sum column Y, Z, AA, AB and AC individually on each tab - two rows below the last data row.
Each data sheet is formatted the same, Header row in Row 5, actual data starts at A:

Tabs 10 through 15 do not have to be summed.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Maybe this, but I have assumed all columns will be the same length
VBA Code:
Sub MM1()
Dim lr As Long, n As Integer
For n = 1 To 10
    Sheets("Sheet" & n).Activate
    lr = Cells(Rows.Count, "Y").End(xlUp).Row
    Cells(lr + 2, "Y").Formula = "=Sum(Y1:Y" & lr & ")"
    Cells(lr + 2, "Z").Formula = "=Sum(Z1:Z" & lr & ")"
    Cells(lr + 2, "AA").Formula = "=Sum(AA1:AA" & lr & ")"
    Cells(lr + 2, "AB").Formula = "=Sum(AB1:AB" & lr & ")"
    Cells(lr + 2, "AC").Formula = "=Sum(AC1:AC" & lr & ")"
Next n
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,308
Members
449,152
Latest member
PressEscape

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