loop through selected worksheeet

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum 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

resolvedResolved · 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 courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Create a unique items table from a duplicating table

1. Ensure that your list has column headings
2. Select the entire list
3. From the menu bar, select DATA, FILTER, ADVANCED FILTER
4. Select "Filter the list, in place", and tick the "Unique Records Only" box
5. Click OK, filtered list appears.

View all Excel hints and tips


Server loaded in 0.08 secs.