sheet reference in if statement

  • Thread starter Thread starter kristing
  • Start date Start date
K

kristing

I was wondering if there was a way to reference a specific sheet whil
writing an if statement in vba for excel. It would be used in an i
statement that would be something like if the sheet exists then g
ahead and run some other functions. Hope someone knows how to do this
 
kristing,

On Error GoTo SheetDoesntExist
Dim myName As String
myName = Worksheets("SheetName").Name
MsgBox "That Sheet Exists"
'Other code

GoTo SheetExists
SheetDoesntExist:
MsgBox "That sheet doesn't exist"
SheetExists:

HTH,
Bernie
MS Excel MVP
 
Back
Top