Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Loop through selected worksheeets with select case
Loop through selected worksheeets with select case
Resolved · Medium Priority · Version 2002/XP
Jenny has attended:
Excel VBA Intro Intermediate course
Excel VBA Intro Intermediate course
Project Management 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
For upcoming training course dates see: Pricing & availability
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
|
