View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Create Worksheet BUT If It Already Exists...

Adapt this to suit
Sub ifsheet()
Application.DisplayAlerts = False
Dim mySheet As String
mySheet = "sheet7"
If mySheet = "" Then Exit Sub
On Error Resume Next
If Sheets(mySheet) Is Nothing Then
MsgBox "no"
'sheets.add
Else
MsgBox "Yes"
'do your thing
'sheets(mysheet).cells.clear'or?

End If
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dave" wrote in message
...
I have the following:

Sub EXAMPLE()
Dim 1WorkSheet As String
1WorkSheet = "Sheet One"
Sheets.Add.Name = 1WorkSheet
Worksheets(1WorkSheet).Visible = xlSheetHidden
End Sub

How do I check, before 1WorkSheet is created, that there is not already a
sheet called "Sheet One". And if there is, use the existing sheet, first
of
all erasing data in it and carrying on as normal?

Thanks!
Dave