macro that adds sheets and names them


Posted by Lino on January 31, 2002 7:01 AM

If I want to add 3 sheets

Sheets.Add Count:=3
How would I add their names automatically.
Name "Sheet1" = "1"
Name "Sheet2" = "2"
Name "Sheet3" = "3"

Thanks

Posted by JohnG on January 31, 2002 7:42 AM

Try this
Sub NameSheets()
Dim NoOfSheets As Integer
Dim NSloop As Integer

NoOfSheets = 3
For NSloop = 1 To NoOfSheets
Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Name = NSloop
Next
End Sub



Posted by Lino on January 31, 2002 9:41 AM

John Thanks,

If I were to substitute text names as my sheet names would it work to simply substitute the numbers for names?
such as Red Yellow Blue

Thanks

Lino