Do not run macro on certain sheets...

cmhoz

Active Member
Joined
Aug 20, 2006
Messages
268
Okay...

I have a macro (or will when i write it!) that loops through each worksheet in the file and runs a macro. This is fine.

However, there a 3 sheets in the files that I want the macro to NOT run on.

So, I was thinking that I would do a select case for these three that lead to and exit sub and a case else that runs the macro.

I'm drawing a blank on one little bit - the syntax to use to determine the name of the sheet...
eg: select case sheets
case sheets("sheet1")
exit sub

select case sheets doesn't work... and apparently neither does my brain!

Thanks!!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi

How about something like
Code:
for each ws in worksheets
  select case ws.name
   case "name1","name2","name3"
    exit sub
    case else
   do your stuff
 end select

next ws


Tony
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top