Sum the same cell in all worksheets

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
Hi is there a way besides using .Formula to say sum all the B6's on the worksheets in a workbook expect for sheet1, and put the results in B6 on sheet1?
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hey,

Say if you had all your sheet names on sheet1 (excluding sheet1 itself) then you can use:

=SUMPRODUCT((SUM(INDIRECT(A1:A2&"!B6"))))

Where A1:A2 contain the other sheet names (Sheet2 & Sheet3) in this small example.

Are there many sheets? You might want to use VBA to generate the sheetnames on to sheet1 if there are.

EDIT: Use something like this to get the sheet names if there are too many to manually write:
Code:
Sub SheetNames()
    Dim nSheets As Long
    Dim i As Long
    nSheets = ActiveWorkbook.Sheets.Count - 1
    Sheets("Sheet1").Activate
    For i = 1 To nSheets
        Cells(i, 1).Value = Sheets(i + 1).Name
    Next i
    
End Sub

This pastes the sheet names (except sheet1) in to column A of sheet1 (Make sure that column A is empty otherwise it will be overwritten!)
 
Last edited:
Upvote 0
If you're looking for VBA:

Code:
    MyTotal = 0
    For Each ws In Worksheets
        If ws.Name <> "Sheet1" Then MyTotal = MyTotal + ws.Range("B6")
    Next ws
    Sheets("Sheet1").Range("B6") = MyTotal
Or you could use a formula:

=SUM(Sheet2:Sheet3!B6)
 
Last edited:
Upvote 0
Or you could use a formula:

=SUM(Sheet2:Sheet3!B6)

I didn't know you could do that cross-worksheet SUM!! I've took note of that for future use, learn something new everyday :-)
 
Upvote 0
@Eric W that code worked great, thanks! I updated it to include NxtRow so that it will continue to sum as data is added.


Code:
With Sheet1
NxtRw = .Cells(Rows.Count, 1).End(xlUp).Row + 1
End With

MyTotal = 0    For Each ws In Worksheets
        If ws.Name <> "Sheet1" Then MyTotal = MyTotal + ws.Range("B" & NxtRw)
    Next ws
    Sheet1.Range("B" & NxtRw) = MyTotal
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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