Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It looks like Chip Pearson's.
Stefi wrote: Not my invention, I found this function in this forum, but I forgot the author's name, sorry! 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 Regards, Stefi €žDamien McBain€ť ezt Ă*rta: Hi, I need to test for the existence of a worksheet with a given name. Presently I'm using some code I found on the net like: On Error Resume Next Set xlobj = Workbooks(WorkBookName).Worksheets(SheetName) If Err = 0 Then do something else do another thing End If I find that this is an awkward way to perform the test because my If..Then..Else is False no matter which error occurs. Is there a more definitive way to perform the test? TIA -- Damien -- Dave Peterson |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave Peterson wrote:
It looks like Chip Pearson's. Stefi wrote: Not my invention, I found this function in this forum, but I forgot the author's name, sorry! 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 Thanks y'all :) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Test for file existence | Excel Programming | |||
Test for file existence | Excel Programming | |||
Existence, Search, Test | Excel Programming | |||
Test for existence of Name | Excel Programming | |||
how do i test for the existence of a range name | Excel Programming |