Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a function that checks if a worksheet exists by For Next-ing through
the Worksheets collection. Function fncSheetExist(SheetName As String) As Boolean Dim sh As Worksheet fncSheetExist = False For Each sh In Worksheets If sh.Name = SheetName Then fncSheetExist = True Next sh End Function In the case there is no workbook open, this code will raise an error (1004) since the Worksheets collection does not exist or is empty. How can I test for that upfront? Without implementing error handling. These do NOT work: - If worksheets.count = 0 .... - If worksheets = Nothing ..... Any ideas? Thanks! -- Message posted via http://www.officekb.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check a collection for objects that may or may not exist within it | Excel Programming | |||
Removing a collection item via key name check | Excel Programming | |||
Workbooks collection is empty even though the some of the document is open | Excel Programming | |||
Check for an item in a collection (without looping) | Excel Programming | |||
worksheets collection... find... | Excel Programming |