loop through selected worksheeet
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

resolvedResolved · Medium Priority · Version 2002/XP

replyReply Tue 8 Jul 2008, 12:25Delegate Jenny said...

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

replyReply Fri 11 Jul 2008, 12:11Trainer Roy said...

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

 

Please browse our web site to find out more about
excel+courses and other Microsoft training courses.

Excel tip:

Purchase excel

Buy MS Excel on Amazon.com

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard