Insert Sheet

G

Guest

What is the code to insert a sheet and name it when it is
insert. This is what I have, but it won't work if there
already is a sheet4.

Sheets.Add
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "Worksheet"

Thank you
 
B

Bob Phillips

Worksheets.Add.Name = "Bob"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
R

Ron de Bruin

Try this

Sub test()
On Error Resume Next
Sheets.Add.Name = "Worksheet"
If Err.Number > 0 Then
MsgBox "Change the name of : " & ActiveSheet.Name & " manually"
Err.Clear
End If
On Error GoTo 0
End Sub
 
Top