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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top