Does a worksheet exist

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I tell if a particular sheet exists in a workbook

If it exists I want to delete it and create a new sheet with the same name

Kaval
 
I guess I could run a little routine to scroll through each sheet in the workbpok and see if I get a match, but I was hoping for a one line solution if possibl

Kaval
 
One way

Sub DelSheet()
Application.DisplayAlerts = False
On Error Resume Next
Sheets("sheet2").Delete
On Error GoTo 0
Application.DisplayAlerts = False
Sheets.Add
ActiveSheet.Name = "SHEET2"

End Su
 
Here is my previous posted code all done on one line

Application.DisplayAlerts = False: On Error Resume Next:
Sheets("sheet2").Delete: On Error GoTo 0: Application.DisplayAlerts =
False: Sheets.Add: ActiveSheet.Name = "SHEET2"
 

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