Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

actions on all workbook sheets except except some sheets

Status
Not open for further replies.

bojzon

IS-IT--Management
Sep 18, 2003
25
SI
Workbook has 23 sheets (named A,B,C,..,O,P,S1,S21,S33)
Sheets(Array("A", "B", "C",....).Select
perform actions (like hiding columns, formating printing,freeze,..)on active sheet, not all selected.

I want to do "actions" on each of 23 sheets in workbook(from A to O) except sheets S1,S21,S33
 
bojzon,

The following will loop through your sheets and execute the desired code;

Sheets("A").Select

Do Until ActiveSheet.Name = "S1"


Your code here.


ActiveSheet.Next.Select

Loop

hope this helps.

Leigh Moore
LJM Analysis Ltd
 
Hi bojzon,

I'm not sure what number base you are using to have 23 sheets named as you have posted, but Leigh is right that there is no special trick - you just have to loop through the sheets and decide whether to do something or not based on whatever criteria you have.

Leigh's code, however, assumes an order to your Sheets which may not be true. You should amend it to check each sheet (I don't know your exact criteria) ...

Code:
For Each Sheet in Sheets
    If not Sheet.name like "S*" then
Code:
' Do your stuff
Code:
    End If
Next

Enjoy,
Tony
 
For i = 1 To ExcelWK.Sheets.Count
xSheet = ExcelWK.Sheets(i).Name
If xSheet <> S1 and xSheet <> S21 and xSheet <> S33 Then

you can do from here anything you want and when loop will meet unwanted criteria - it'll skip to the

NEXT

Have fun !!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top