Does a worksheet exist

K

Kaval

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
 
K

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
 
M

mudraker

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
 
M

mudraker

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"
 
Top