Sheet Exist Function ????

J

John Smith

Are there any ways to examine weather a sheet name exist in th
workbook? Something like:

= ExistSheet(“SheetName”)

that returns a TRUE if the Sheet name exist or a FALSE if it do no
exist
 
F

Frank Kabel

Hi
either use a VBA function or try the following:
=IF(ISERROR(INDIRECT("'sheetname'!A1")),"does not exits","does exist")

Note: This won't work if cell A1 on your referenced sheet contains an
error
 
B

Bob Phillips

Here is a UDF

'-----------------------------------------------------------------
Function SheetExists(Sh As String, _
Optional wb As Workbook) As Boolean
'-----------------------------------------------------------------
Dim oWs As Worksheet
If wb Is Nothing Then Set wb = ActiveWorkbook
On Error Resume Next
SheetExists = CBool(Not wb.Worksheets(Sh) Is Nothing)
On Error GoTo 0
End Function
 
H

Harlan Grove

Frank Kabel said:
either use a VBA function or try the following:
=IF(ISERROR(INDIRECT("'sheetname'!A1")),"does not exits","does exist")

Note: This won't work if cell A1 on your referenced sheet contains an
error
....

So why do it this way? Make your ISERROR term slightly more complicated.

ISERROR(CELL("Address",INDIRECT("'sheetname'!A1")))
 

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

Top