Macro to sum cells from other sheets into one

Closed
maz - Nov 24, 2010 at 05:04 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Nov 25, 2010 at 04:25 AM
Hello, I want to sum cells from other sheets which have the same format, into one sheet using a macro (ie instead of the manual excel function =sum(sheet1,A1+Sheet2,A1 etc).
Any help is greatly appreciated

Thanks



1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Nov 25, 2010 at 04:25 AM
I prsume you want sheet1!a1+sheet2!a1+sheet3!a1 etc

insert a new sheet and call it "master"

try this macro (the total pops up and also copied in A1 of sheet "master"


Sub test()
Dim j As Long, k As Long, tot As Double
j = Worksheets.Count
tot = 0
For k = 1 To j
If Worksheets(k).Name <> "master" Then
tot = tot + Worksheets(k).Range("A1")
End If
Next k
MsgBox tot
Worksheets("master").Range("A1") = tot
End Sub
1