ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I cycle through all of the worksheets (https://www.excelbanter.com/excel-discussion-misc-queries/63863-how-do-i-cycle-through-all-worksheets.html)

DMB

How do I cycle through all of the worksheets
 
I need to check all of the worksheets to collect and sum contents. Is there a
with method or something along those lines?

WITH worksheets
if a = b then
Total = a1 + a1
end if
end with


Bob Phillips

How do I cycle through all of the worksheets
 
For Each sh In Activeworkbook.Worksheets
If Range("A1").Value = Range("B1").Value Then
myTotal = myTotal + Range("A1").Value
End If
Next sh

--

HTH

RP
(remove nothere from the email address if mailing direct)


"DMB" wrote in message
...
I need to check all of the worksheets to collect and sum contents. Is

there a
with method or something along those lines?

WITH worksheets
if a = b then
Total = a1 + a1
end if
end with





All times are GMT +1. The time now is 06:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com