Im trying to figure out the right way to code a macro that goes through 12 worksheets with specific names (Jan,Feb,...,Dec). I thought maybe for each function will be a good choice so i tried the following:
dim crntSht as worksheet
set crntsht=("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
for each crntsht in worksheets
.
.
.
end for
this obviously did not work since I defined crntsht in the wrong manner.
Can anyone suggest the best way to loop through all 12 sheets once each, and skip all other sheets in the same workbook?
Thanks
Ah, Tim beat me... my answer is slightly different however...
Sub LoopThroughSheets()
Dim Months As Variant
Dim Month As Variant
Months = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", _
"Aug", "Sep", "Oct", "Nov", "Dec")
For Each Month In Months
'Code goes here.
Next Month
End Sub
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments