# Sum the same cell in all worksheets

#### helpexcel

##### Well-known Member
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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

#### tyija1995

##### Well-known Member
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:

#### Eric W

##### MrExcel MVP
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:

#### tyija1995

##### Well-known Member
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

#### helpexcel

##### Well-known Member
@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``````

1,102,730
Messages
5,488,540
Members
407,643
Latest member
samerf86

### This Week's Hot Topics

• Timer in VBA - Stop, Start, Pause and Reset
[CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
• how to updates multiple rows in muliselect listbox
Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
• Delete Row from Table
I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
• Assigning to a variable
I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
• Way to verify information
Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
• Active Cell Address – Inactive Sheet
How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...