How can I tell if a worksheet exists?
Sub Test()
MsgBox SheetExist("A")
End Sub
Function SheetExist(shName) As Boolean
Dim sh As Worksheet
On Error GoTo Err_SheetExist
Set sh = Worksheets(shName) 'if worksheet exist, object sh is set
SheetExist = True
Set sh = Nothing 'we don't need this object
Exit Function
Err_SheetExist:
SheetExist = False 'worksheet not existing
Set sh = Nothing 'free memory
End Function
--
Sorry for my language, I'm still learning
losmac
Użytkownik "Robert Stober" napisał w wiadomości
...
Hi,
I want to determine if a worksheet named Sheets("Chart") exists. How can I
do this using VBA?
Thank you,
Robert Stober
|