Jenny has attended:
Excel VBA Intro Intermediate course
Excel VBA Intro Intermediate course
Project Management - Framework & Processes course
Excel VBA Advanced course
Loop through selected worksheeets with select case
Hi
I am trying to loop through selected worksheets, using a select case statement to exclude the unwanted worksheets. I have the below code but it doesn't loop at all; it just updates the active sheet. Could you let me know where I am going wrong? "Copied Sheeet" is the name of the worksheet I want to exclude.
Thank you - Jenny.
Sub LoopWorkSheets()
Dim mySheet As Worksheet
For Each mySheet In Worksheets
Select Case mySheet.Name
Case "CopiedSheet"
Case Else
Range("A3").Font.Color = vbRed
End Select
Next mySheet
End Sub
RE: Loop through selected worksheeets with select case
You need to say:
mySheet.Range("A3").Font.Color = vbRed
If you just say Range("A3")... you get the range on the ActiveSheet.
Althernatively, you could do mySheet.Activate within the loop.
/Roy MacLean