One More Visual Basic Question

  • Thread starter Thread starter lj
  • Start date Start date
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.
 
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)
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top