marco for totalling different length sheets

Oldmillrob

New Member
Joined
Sep 18, 2018
Messages
1
I want to record a Marco to total column J and put the total at the end of the list. The difficulty is that I want to use this Marco on lists of various sizes. the curser May be anywhere on the sheet and when Marco is run it should always go to the end of column J. One sheet may be 250 lines and the next could be 3200. Thefore the total cell will be in different places in different sheets. I am not experienced in VB
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Code:
Sub loopit()


         ' Declare Current as a worksheet object variable.
         Dim Current As Worksheet


         ' Loop through all of the worksheets in the active workbook.
         For Each Current In Worksheets
if current.visible = true 'only visible sheets
lastrow = current.Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row            
current.cells(lastrow+1,"J") = worsheetfunction.sum(current.range("J:J"))
endif
         Next


      End Sub
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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