Thread: Sheet Criteria
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Sheet Criteria



'-----------------------------------------------------------------
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.Sheets(Sh) Is Nothing)
On Error GoTo 0
End Function


?SheetExists("Chart1")

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Kerry Purdy" wrote in message
...
Hi

If the sheet (chart 1) does not exist in my workbook then I would like to
run my macro, otherwise not. How can I search the book to see if the

chart1
sheet exists?

Many thanks

Kerry