Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Vasant "Steve" wrote in message ... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. -----Original Message----- 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 . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 "Steve" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loop worksheets | Excel Discussion (Misc queries) | |||
Loop thru files in DIR, delete worksheets & reset worksheet Name property?? | Excel Programming | |||
Renaming Worksheets with For Each Loop | Excel Programming | |||
Excel macro to loop through worksheets and graph data from each worksheet | Excel Programming | |||
Conditional Lookup and copy loop between worksheets | Excel Programming |