View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Making sheets with a macro

Hi James,

Sub Test()
Dim i As Long
Dim wks As Worksheet

On Error Resume Next

Set wks = ActiveWorkbook.Worksheets("Insert Name")

If wks Is Nothing Then
Set wks = ActiveWorkbook.Worksheets.Add
wks.Move after:=Sheets(Sheets.Count)
wks.Name = "Insert Name"
End If

Err.Clear
For i = 1 To 6
Set wks = Worksheets("Something Else" & i)
If Err.Number Then
Exit For
Else
Err.Clear
End If
Next

On Error GoTo 0
If i = 7 Then
MsgBox "already 6"
Else
Worksheets.Add.Move after:=wks
ActiveSheet.Name = "Something Else" & i
End If
End Sub

Regards,
Peter T

"JamesJordan" wrote in message
ups.com...
Hello everybody. I could really use some help with trying to do this.
I have run into an issue where i want to be able to create multiple
sheets with a macro. I am trying to create a macro that can be used to
see if a sheet "Insert Name" exists. The once it is verified then
create an additional sheet called "Something Else". Also, I want to it
to only add one planned sheet each time you run the macro and to name
each new sheet differently. I would like to be able to do this for up
to six new sheets. Is this even possible? If it is not possible please
tell me so I do not waste more time trying. If it is possible I would
really appreciate some help or hints on this subject.


-James-