I have 100 worksheets in a file. I need to export every 4 worksheets into a seperate file so I have a total of 25 new files.
I have 100 worksheets in a file. I need to export every 4 worksheets into a seperate file so I have a total of 25 new files.
Maybe:
![]()
Please Login or Register to view this content.
The code above exports each worksheet as new file, not every 4 worksheets.
The code provided was untested and it actually error'd out for me. However I revised it. See if this helps.
BTW it does copy to a new workbook.![]()
Please Login or Register to view this content.
Give a chance to next code
The macro is hosted in the file attached and can be used as a toolbox
The original file (with data )must be loaded in Excel, its name is "OrgFile.xlsx" : Adapt it to your need
All files prepared are recorded in the same folder as the toolbox (active file) and are named "DestFile" plus an index. If there is some files with the same name they are replaced by the new file.
![]()
Please Login or Register to view this content.
Last edited by PCI; 07-21-2015 at 03:20 PM. Reason: additional info added
- Battle without fear gives no glory - Just try
I tried both macros on my data. Neither one worked.
Did you activate the original workbook (source) before you ran the macro? What happens when you run the codes? Are the sheets names different? They need to be.
I've attached a sample file with 9 tabs. Ideally, the macro would have created 3 new files (File 1 with tabs Jan14-Aprl14 only, File 2 wih Jan15-Apr15 tabs only,File 3 with only Jan16). The result is attached. It inserted "Sheet 1" and copied every 4th tab.
It means it did not run with file sent: PrepareFile.xlsm ???
Maybe:
![]()
Please Login or Register to view this content.
John- that works. Thank you.
PCI- that's correct. It did not run with file.
You're welcome. Glad to help out and thanks for the feedback.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks