Hallo guys,
-Windows XP
-Excel 2010
I need to add 3 new spreadsheets giving them a name taken from a range in another sheet. I used the code below, but after that excel creates the first new spreadsheet with the correct name, it creates the second sheet with the generic name (ex. Sheet17) and then I got the following error:
Run-time error ‘1004’
Application-defined or object-defined error.
Sub NewSheets()
For i = 2 To 4
Worksheets.Add().Name = Worksheets(14).Cells(i, 8).Value
Next i
End Sub
In general I would need to create n sheets giving them the name taken from a range made of n cells. n is variable. So I thought that the cycle “For” would fit my needs. If you think that there is a better way, please let me know!
Thanks
Scorpione
-Windows XP
-Excel 2010
I need to add 3 new spreadsheets giving them a name taken from a range in another sheet. I used the code below, but after that excel creates the first new spreadsheet with the correct name, it creates the second sheet with the generic name (ex. Sheet17) and then I got the following error:
Run-time error ‘1004’
Application-defined or object-defined error.
Sub NewSheets()
For i = 2 To 4
Worksheets.Add().Name = Worksheets(14).Cells(i, 8).Value
Next i
End Sub
In general I would need to create n sheets giving them the name taken from a range made of n cells. n is variable. So I thought that the cycle “For” would fit my needs. If you think that there is a better way, please let me know!
Thanks
Scorpione