+ Reply to Thread
Results 1 to 2 of 2

If Worksheet Name Does not equal more than one.

Hybrid View

  1. #1
    Registered User
    Join Date
    08-12-2009
    Location
    Cardiff, Wales
    MS-Off Ver
    Excel 2007
    Posts
    53

    If Worksheet Name Does not equal more than one.

    Need help with the following simple line of code. It runs the macro perfectly for all sheets other than the one stated in the following line:
    If Worksheet.Name <> "Sheet1" Then
    But I need it to exclude more than on sheet, e.g:
    If Worksheet.Name <> "Sheet1" or "Sheet2" or "Sheet3" etc......... Then
    but cant get it to work, all help much appreciated.

    Thanks

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: If Worksheet Name Does not equal more than one.

    Hi,
    you could use Select Case statement instead of If statement. Like this

        Select Case MyWorksheetName
        Case "Sheet1", "Sheet2"
            'Do nothing
    
        Case Else
            'Do something
    
        End Select
    Assuming MyWorksheetName is variable that holds the sheet name you want to check. There may be other solutions, but that's the first that comes to my mind based on information provided.
    If you are pleased with a member's answer then use the Star icon to rate it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1