Ignore a number of sheets before checking rest

adamprocter

Board Regular
Joined
Apr 13, 2015
Messages
53
I have a macro button on sheet 1 to check sheets for a certain piece of data which is great but I need to ignore sheets 1 2 and 3

Code:
Dim ws As Worksheet
If ws.Name <> "My sheet 1" Or "My sheet 2" Or "My sheet 3" Then

Cant seem to figure it out
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Code:
Sub x()
Dim ws As Worksheet


Application.ScreenUpdating = False


For Each ws In ThisWorkbook.Worksheets
    Select Case ws.Name
        Case "Sheet1", "Sheet2", "Sheet3"
        Case Else:
            'your code here
    End Select
Next ws


Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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