Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sheet Criteria
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sheet Criteria
Kerry,
Try something like Dim SH As Object On Error Resume Next Set SH = Sheets("Chart1") If SH Is Nothing Then Debug.Print "Sheet does not exist" Else Debug.Print "Sheet exists." End If -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com (email address is on the web site) "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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy from sheet to sheet when matches criteria | Excel Worksheet Functions | |||
Auto Copy/autofill Text from sheet to sheet if meets criteria | Excel Discussion (Misc queries) | |||
Move data to new sheet - rename sheet based on criteria ? | Excel Discussion (Misc queries) | |||
Need to look up value in another Sheet based on criteria in first sheet. | Excel Worksheet Functions | |||
Excel VBA (?!)-refer to a cell on Sheet to left of X, based on criteria on Sheet X | Excel Programming |