98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Loop through selected worksheeets with select case | Excel forum
Loop through selected worksheeets with select case | Excel forum
Resolved · Medium Priority · Version 2002/XP
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
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Create a unique items table from a duplicating table1. Ensure that your list has column headings |