View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JW[_2_] JW[_2_] is offline
external usenet poster
 
Posts: 638
Default Sum values form different tabs

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
vlad wrote:
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