Sum values form different tabs

V

vlad

I need a macro that will sum the values from Cell A7 from every tab in the
current spread sheet however excluding three tabs " SheetABC", "SheetMNH" and
"SheetXYZ" and insert the result in Cell A7 in "SheetMNH"
Then i want to do the same with the values in Cell A8, A9, A10 and A11 and
put the results in A8, A9, A10 and A11 in "SheetMNH".
Any help will be very much appreciated!
Thanks
 
J

JW

Couple different ways this could be done. Here is a quickie. This
will do A7 through A11. If you need to go further than row 11, just
change the finalRow variable.
Sub sumThis()
Dim ws As Worksheet, finalRow As Long
Dim mainWS As Worksheet, s As Long
Dim i As Integer 'change to Long if needed
Set mainWS = Sheets("SheetMNH")
finalRow = 11 'change as needed
For i = 7 To finalRow
s = 0
For Each ws In ActiveWorkbook.Worksheets
If Not ws.Name = "SheetMNH" _
And Not ws.Name = "SheetABC" _
And Not ws.Name = "SheetXYZ" Then _
s = s + ws.Cells(i, 1)
Next ws
mainWS.Cells(i, 1) = s
Next i
Set mainWS = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top