Check for a tab if it is exist

  • Thread starter Thread starter Farhad
  • Start date Start date
F

Farhad

Hi all,

i want to check in an Excel file for a tab name for example "AAA" and see if
this tab name is exist in the file or not everyone please help me.

Thanks,
 
Something like this function should work...

Private Function SheetExists(sname) As Boolean
On Error Resume Next
IsError ActiveWorkbook.Sheets(sname)
SheetExists = Err.Number = 0
End Function

Just call it from your own code (macro, function, event procedure, etc.)
like this...

MsgBox SheetExists("AAA")

The function returns True if the sheet exists and False if it doesn't exist.
 
Back
Top