Loop worksheets

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I want to have a loop

For loopnum = 1 To 10

In the loop I want to create a new worksheet in each
loop, name the sheet the sheets number spelled out
("one", "two", "three" ...) and write the name of the
sheet in cell A1 of each sheet.

How do I do that ?

Thanks
Steve
 
Something like:

Sub NameWorksheets()
Dim wsNames As Variant, loopnum As Integer, ws As Worksheet
wsNames = _
Array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight",
"Nine", "Ten")
For loopnum = 9 To 0 Step -1
Set ws = Worksheets.Add(After:=Worksheets(1))
With ws
.Name = wsNames(loopnum)
.Range("A1") = ws.Name
End With
Next
End Sub
 
If it is easier, it would be helpful for me to know how
to do something like name the new sheets all the same
thing with a number after them, like: results1,
results2, results3, ..., results10 and put the number of
the sheet in cell A1.
 
Hello Steve,

Is this what you want?

Sub testme()
For loopnum = 1 To 10
ActiveWorkbook.Sheets.Add after:=Sheets(Sheets.Count)
With ActiveSheet
Select Case loopnum
Case 1
.Name = "One"
Case 2
.Name = "Two"
'and so on
End Select
End With
Next loopnum
End Sub

Regards,

Jon-jon
 
Back
Top