Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If worksheet from array exists then not working
Hi-I have an array that before it loops throught the code to create
worksheets i need to determine if the worksheet name already exists. If it does I want a msgbox to appear then exit the sub. I created the code below but it does not work. Error:Run time 438 Object doesn't support this property or method. If ThisWorkbook.Worksheets(MyArray(i, j)).Exists Then MsgBox "Cost Centres already exist." Exit Sub Else Please help. Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If worksheet from array exists then not working
Here is some code to check
'----------------------------------------------------------------- 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 -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message ps.com... Hi-I have an array that before it loops throught the code to create worksheets i need to determine if the worksheet name already exists. If it does I want a msgbox to appear then exit the sub. I created the code below but it does not work. Error:Run time 438 Object doesn't support this property or method. If ThisWorkbook.Worksheets(MyArray(i, j)).Exists Then MsgBox "Cost Centres already exist." Exit Sub Else Please help. Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VLOOK up returning #N/A even though value exists in lookup array | Excel Worksheet Functions | |||
Lookup value - see if exists in another array | Excel Worksheet Functions | |||
Macro in Excel using an Array to Delete File in Directory if it Exists | Excel Programming | |||
need array of true/false if text exists | Excel Worksheet Functions | |||
How to check if a worksheet exists in worksheet collection | Excel Programming |