Macro for SUM of colums....many worksheets!

chefdt

Board Regular
Joined
Jul 1, 2008
Messages
163
I have a workbook with 90+ sheets. Each sheet's format is the same, with different data. I need a macro that will SUM four different columns from EACH sheet. The number of ROWS in each sheet varies....

The columns are F,G,H,I, and the data starts in ROW 2.

Can anyone help?

Dale
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi, Try this:-
Sum of each column inserted 2 rows after end of each column.
Code:
Dim wksh As Worksheet, rng As Range, oSum As Integer, oCol As Integer
Dim oAd, oLet
For Each wksh In ActiveWorkbook.Worksheets
   
   For oCol = 6 To 9
    oAd = Cells(2, oCol).Address(0, 0)
        oLet = Split(Cells(2, oCol).Address, "$")(1)
            Set rng = Sheets(wksh.Name).Range(oAd, Sheets(wksh.Name) _
                .Range(oLet & Rows.Count).End(xlUp))
                     oSum = WorksheetFunction.Sum(rng)
            Sheets(wksh.Name).Cells(rng.Count + 3, oCol) = oSum
    Next oCol
Next wksh

MsgBox "Sums Complete"
Regards Mick
 
Last edited:
Upvote 0
try this

Code:
Dim wb As Workbook
Dim ws As Worksheet
Dim LstShtRow As Long
Dim clm As Integer

Set wb = ThisWorkbook

For Each ws In wb.Worksheets
    'find the last row assuming each column has the same amount
    'of rows, and is looking in column A for the last row
    LstShtRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
    'sum columns F,G,H,I or 6,7,8,9
    For clm = 6 To 9
        ws.Cells(LstShtRow + 1, clm).Formula = _
            "=SUM(" & ws.Cells(2, clm).Address & ":" & ws.Cells(LstShtRow, clm).Address & ")"
    Next clm
Next ws
 
Upvote 0
if the sheets are positioned in sequence insert a sheet called START before first sheet and another called END after the last of the 90 sheets -- then simply use

=SUM(START:END!F:I)
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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