View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_676_] joel[_676_] is offline
external usenet poster
 
Posts: 1
Default Sum up values in each column in 12 different worksheets and displayvalue in a MsgBox


Here are two methods. Te method to use depends on the number of sheets
in the workbook you want included and the number of sheets you want to
exclude from the total.

MyTotal = 0
for each sht in sheets
if sht.name < "Summary" and sht.name < "Cover Sheet" then
with sht
Lastrow = .Range("C" & rows.count).end(xlup).row
Set MyRange = .Range("1:" & LastRow)
Total = Total + worksheetfunction.sum(Myrange)
end with
end if
next sht
msgbox("the total is : " & Mytotal)



shtNames = array("sheet1","sheet3",sheet5")
MyTotal = 0
for each sht in shtnames
with sheets(sht.name)
Lastrow = .Range("C" & rows.count).end(xlup).row
Set MyRange = .Range("1:" & LastRow)
Total = Total + worksheetfunction.sum(Myrange)
end with
next sht
msgbox("the total is : " & Mytotal)


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=179907

Microsoft Office Help