Bus w**ker
Hi,
After spending the past seven and a half hours trying to get this to work I have admitted defeat.
What I'm attempting to do is copy 27 worksheets, names set in a range "nao_sheets", paste them in to the same workbook in any position (although a new workbook would also be fine) and then rename the copied sheet with the same name as the original worksheet but prefixed with the days date; i.e. 20110523 - Frontpage.
The code below works flawlessly for the first 15 worksheets, but then fails for any after with the error
I've tried to rename all the sheets to single characters, deleted sheets that could possibly be troublesome, different variations of the above code (especially the copying line), cried a little and sworn a lot. Sadly none of this has helped and the outcome has been exactly the same, to add to my misery I'm forced to use XP SP3 and Excel 2003.
Really grateful for any advice people can offer, before I tear out the little hair I have left.
Thanks!
Sy
After spending the past seven and a half hours trying to get this to work I have admitted defeat.
What I'm attempting to do is copy 27 worksheets, names set in a range "nao_sheets", paste them in to the same workbook in any position (although a new workbook would also be fine) and then rename the copied sheet with the same name as the original worksheet but prefixed with the days date; i.e. 20110523 - Frontpage.
The code below works flawlessly for the first 15 worksheets, but then fails for any after with the error
Debug highlights the line shown in bold.Run-time error '1004':
Copy method of Worksheet class failed
Code:
Sub testing2()
Dim cell As Range
Dim nao_Today As String
Dim nao_sheetname As String
nao_Today = Format(Date, "yyyymmdd")
For Each cell In Range("nao_sheets")
Sheets(cell.Value).Select
nao_sheetname = ActiveSheet.Name
[B]ActiveSheet.Copy After:=ActiveSheet[/B]
Sheets(cell.Value & " (2)").Select
ActiveSheet.Name = nao_Today & " " & nao_sheetname
Next cell
End Sub
Really grateful for any advice people can offer, before I tear out the little hair I have left.
Thanks!
Sy