Save New Workbooks Quickly

Sisb

New Member
Joined
Jul 9, 2012
Messages
3
Hello All,

I am trying to take a few sheets from a workbook and create a new workbook with them. I have been using the following code listed below and It works. The problem is that it is somewhat slow. I have this in a loop and need to run it a few hundred times which is time consuming.

Is there a way to create a new workbook with these sheets without having to open it and close it again? Or any other way that might be faster?



Sheets(Array("Sheet1", "Sheet2", "Sheet4", "Sheet5")).Copy

ActiveWorkbook.SaveAs Filename:=xlsPath + "\ASSET ID " & asset & " " & recdate & " " & ".xls", CreateBackup:=False

ActiveWorkbook.Close



Thank You,

Sisb
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

matttclark

Board Regular
Joined
Jan 13, 2011
Messages
100
Sisb,

Not sure if I can be of help, can you provide more details on what you are doing?

For instance, are you looping through what I will call the 'master file' and filtering data, then copying the sheets to a new workbook?

Or are you making copies of the same sheets and data just naming them differently for some reason?

Also, is the data just updated or does it grow?

The same set of hundreds of filenames, do they change?

any other details that may help
matt-
 

Sisb

New Member
Joined
Jul 9, 2012
Messages
3
Matt,

I am looping through a part the Master Sub. In the loop I scrub a few websites for data about a specific asset. Then dump and format that data into Sheets 1, 2, 4, and 5. Then Pull some key points from each sheet and append them to a results sheet.

After that one pass through the loop I want to save down the 4 unique sheets and then I clear them in preparation for the next pass. The new file serves as a tool later on in a deeper investigation of that specific asset. Each new file has a unique name with the asset ID in it.

The problem is I timed the new file creation part of the loop and it takes 7 seconds, with the code I posted. Repeated several hundred times this is too long.

Any ideas for how to speed up the process would would be welcome.

Thanks,

Sisb


Code:
[COLOR=#574123]Sheets(Array("Sheet1", "Sheet2", "Sheet4", "Sheet5")).Copy[/COLOR]

[COLOR=#574123]ActiveWorkbook.SaveAs Filename:=xlsPath + "\ASSET ID " & asset & " " & recdate & " " & ".xls", CreateBackup:=False[/COLOR]

[COLOR=#574123]ActiveWorkbook.Close[/COLOR]
 

Watch MrExcel Video

Forum statistics

Threads
1,122,233
Messages
5,594,964
Members
413,955
Latest member
FalcoDaz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top