Check for a tab if it is exist

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,
 
R

Rick Rothstein

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.
 
Top