Q:

Perform Action IF the active sheet is one of a group of sheets

I'm trying to clear rows in a worksheet.
I found ActiveSheet.Range(range).Clear.
I have similar looking worksheets in the workbook and I am trying to protect myself from accidentally deleting stuff I need.
I am trying to check if the active sheet is one of 7 worksheets in the workbook. If it isn't, don't clear.
If Not ActiveSheet.Name = Worksheets("014").Name Then

Else
    ActiveSheet.Range("40:42").Clear
End If

This works for a single worksheet, but I need to check for 6 more sheet names. I can code this with multiple "IF NOT" statements checking for each sheet, but is there a shorter, cleaner way to check all seven worksheet names in the same "IF NOT" statement?

A:

Put all of the sheet names into one string and then use that.
Dim strSheetNames as String
Dim ws As Worksheet
Set ws = ActiveSheet
strSheetNames = ",Sheet1,Sheet2,Sheet3,014..," 'include all sheet names
If InStr(strSheetNames,"," & ws.Name & ",") <> 0 Then
      ws.Range("40:42").Clear
End If

The comma searching trick is per Zev Spitz.

