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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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,213,517
Messages
6,114,085
Members
448,548
Latest member
harryls

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