Thread
:
Create Worksheet BUT If It Already Exists...
View Single Post
#
3
Posted to microsoft.public.excel.misc
Don Guillett
external usenet poster
Posts: 10,124
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
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett