ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Making sheets with a macro (https://www.excelbanter.com/excel-programming/350214-making-sheets-macro.html)

JamesJordan

Making sheets with a macro
 
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-


Peter T

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-




JamesJordan

Making sheets with a macro
 
Thanks I will try that out. That should give me a good start. I will
already have a couple of sheets in the workbook. Also, I am messing
with a macro to create a corresponding sheet for each sheet that is
created. What it is, is that I will use the code you gave me to create
a macro that makes multiple planned pages and then I hope to be able to
run the another macro to create a planned vs. actual sheet for each of
the planned sheets that exist. I appreciate your help!

-James-



All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com