Hi all,
Tried to find a solution for this but it seems I'll be the first to attempt it.
I have a workbook containing several sheets, there are 7 permanent sheets that I have renamed as Sheet01 to Sheet07 and a growing number of other sheets.
A macro allows the users to create a new set (project) which duplicates 2 templates among other actions like retrieving information from an external source.
This has been working before but the workbook has become ginormous and takes forever to calculate.
So I decided to split it in 2 documents, 1 does the importing (the above action) while the second will work as reporting tool.
The import bit I managed to make it work with no issues.
What I need to produce now is a macro that will copy the sheets from Sheet07 (excluding it) to the last one (latest).
The newer sheets will have as name 6 or 8 digits and characters a space and ending with M and E (123456 M, 123456 E or 123456.1 M 123456.1 E).
My initial approach was to try to use something like:
Dim r As Long, lr As Long
Dim sh As Worksheet
For Each sh In Worksheets(Array(sheet08.Name, , sheet10000.Name))
sh.Copy After:=Workbooks("Book.xlsm").Sheets(Workbooks("Book.xlsm").Worksheets.Count)
Next
The intention was that the macro would ignore all sheets before Sheet08 and will copy everything after it in this case to a limit of 10,000 sheets.
I am under the impression that Array used in the way I'm trying to doesn't work.
The question:
What is the code that I should use?
thank you in advance.
Tried to find a solution for this but it seems I'll be the first to attempt it.
I have a workbook containing several sheets, there are 7 permanent sheets that I have renamed as Sheet01 to Sheet07 and a growing number of other sheets.
A macro allows the users to create a new set (project) which duplicates 2 templates among other actions like retrieving information from an external source.
This has been working before but the workbook has become ginormous and takes forever to calculate.
So I decided to split it in 2 documents, 1 does the importing (the above action) while the second will work as reporting tool.
The import bit I managed to make it work with no issues.
What I need to produce now is a macro that will copy the sheets from Sheet07 (excluding it) to the last one (latest).
The newer sheets will have as name 6 or 8 digits and characters a space and ending with M and E (123456 M, 123456 E or 123456.1 M 123456.1 E).
My initial approach was to try to use something like:
Dim r As Long, lr As Long
Dim sh As Worksheet
For Each sh In Worksheets(Array(sheet08.Name, , sheet10000.Name))
sh.Copy After:=Workbooks("Book.xlsm").Sheets(Workbooks("Book.xlsm").Worksheets.Count)
Next
The intention was that the macro would ignore all sheets before Sheet08 and will copy everything after it in this case to a limit of 10,000 sheets.
I am under the impression that Array used in the way I'm trying to doesn't work.
The question:
What is the code that I should use?
thank you in advance.