Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to create a number of copies of my existing sheet through a
for...next loop. Here is the code that I am trying to use. Public Sub Copies30() Dim I As Integer Dim Sheetname As String For I = 1 To 30 Sheetname = "PC " & Str(I) ThisWorkbook.Worksheets(Sheetname).Copy after:=Worksheets(Sheetname) Next I End Sub When stepping through this, I am getting a "subscript out of range error". I can't understand why, as if I add a watch on Worksheets("PC 1"), I am able to get a reference to the worksheet. Is there anyone who can spot the problem? Thanks in advance, Greg |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copying sheets | Excel Worksheet Functions | |||
Copying Sheets | Excel Worksheet Functions | |||
Copying Sheets | Excel Discussion (Misc queries) | |||
copying sheets | Excel Discussion (Misc queries) | |||
Copying sheets | Excel Programming |