I have a load of code that creates two worksheets, then code to Move the sheets to a new workbook, rename the workbook, save and close. All fine.
But, I need to remove the Names from the sheets.
This is my code block - the ".Move" line is fine. (I tried .COPY instead of .MOVE, same result)
After 1 iteration through the For loop, I get a 400 error.
No names have been removed.
Dim NameRange As Name
Sheets(Array(Sht01, Sht02)).Move
For Each NameRange In Application.ActiveWorkbook.Names
NameRange.Delete
Next
Any ideas what the problem might be?
None of the Names are special - not system names. Just PrintRange and then some Names i defined for coding.
But, I need to remove the Names from the sheets.
This is my code block - the ".Move" line is fine. (I tried .COPY instead of .MOVE, same result)
After 1 iteration through the For loop, I get a 400 error.
No names have been removed.
Dim NameRange As Name
Sheets(Array(Sht01, Sht02)).Move
For Each NameRange In Application.ActiveWorkbook.Names
NameRange.Delete
Next
Any ideas what the problem might be?
None of the Names are special - not system names. Just PrintRange and then some Names i defined for coding.
Last edited: