VBA: Activate sheets within a loop
You have wSheet declared as a worksheet. I assume it needs to be declared as
a String, because it looks like you are looping through a list of sheet
names. This is how you should declare it
Dim wSheet As String
I actually recommend you looping through your sheets like this instead.
You don't have to activate the sheet to calculate it. Hope this helps! If
so, let me know, click "YES" below.
Sub LoopThroughSheets()
Dim i As Long
i = 5
Do While Sheets("Print Tracks").Cells(i, "G").Value < ""
Sheets(Cells(i, "G").Value).Calculate
i = i + 1
Loop
End Sub
--
Cheers,
Ryan
"CM4@FL" wrote:
I want to loop through a list of sheets, why won't the following code allow
me to activate a sheet? Thanks for your help in advance!
Sub LoopThroughSheets()
Dim wSheet As Worksheet
i = 5
wSheet = Sheets("Print Tracks").Range("G" & i).Value
Do While wSheet < ""
Sheets(wSheet).Activate
Calculate
i = i + 1
wSheet = Sheets("Print Tracks").Range("G" & i).Value
Loop
End Sub
|