One More Visual Basic Question

L

lj

Hi, I'm creating a macro and wanted to know if there's a way (and what
the syntax would be) to have the macro look to see if a particular
worksheet exists and if it does delete it and if it doesn't exisit to
continue moving on in the macro. Thanks for your help.
 
B

Bob Phillips

Dim sh As Worksheet

On Error Resume Next
Set sh = Worksheets("Sheet to be deleted"
On Error Goto 0
If Not sh Is Nothing Then
Application.DisplayAlerts = False
sh.delete
Application.DisplayAlrerts = True
End If

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
L

lj

Thanks, this was exactly what i was looking for!

Bob said:
Dim sh As Worksheet

On Error Resume Next
Set sh = Worksheets("Sheet to be deleted"
On Error Goto 0
If Not sh Is Nothing Then
Application.DisplayAlerts = False
sh.delete
Application.DisplayAlrerts = True
End If

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
Top