Shortening and speeding up a data extract macro

Bobstar

New Member
Joined
Oct 7, 2020
Messages
20
Office Version
  1. 2019
Platform
  1. Windows
Hi all

I monitor a range of portfolios and each quarter; I get performance data of the portfolios from an external provider. For each portfolio, I get 4 sets of data. These files/workbooks are then saved in a folder.
I have created a dashboard that summarises these data in charts. The dashboard allows a user to input the portfolio name and path of the files and fetches the data.

In summary, the process is as follows:

1. User selects/enters portfolio name (cell “F6”) and file path (cell “J6”) where the source files are stored and clicks a button to fetch the data.

2. Macro opens the four source files and copies the data in sheet1 (“Attribution”) to different sheets in the Masterfile/dashboard.

3. Using portfolio 1 as an example, macro copies data as follows:
  • Data in sheet 1 of Portfolio1 vs BM(1) – level 1a workbook is copied to sheet(“BM(1)_level1a”)
  • Data in sheet 1 of Portfolio1 vs BM(1) – level 1b workbook is copied to sheet(“BM(1)_level1b”)
  • Data in sheet 1 of Portfolio1 vs BM(2) – level 1a workbook is copied to sheet(“BM(2)_level1a”)
  • Data in sheet 1 of Portfolio1 vs BM(2) – level 1b workbook is copied to sheet(“BM(2)_level1b”)
The following macro does the job, but I am looking for ideas on how to simplify it so that it can run faster. At the moment it is taking around 8-10 seconds.

Thanks
Capture.PNG
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
The first thing I would try is just using the same code but reordering the code so that you only deal with one workbook at a time , ie. open the workbook , then determine the last row, then copy the data then close the workbook. then do the next workbook. This will save EXCEL needing to continually swap between workbooks on every step of your code.. Also it might reduce the amount of memory needed
 
Upvote 0
The first thing I would try is just using the same code but reordering the code so that you only deal with one workbook at a time , ie. open the workbook , then determine the last row, then copy the data then close the workbook. then do the next workbook. This will save EXCEL needing to continually swap between workbooks on every step of your code.. Also it might reduce the amount of memory needed
Thanks I will give it a try.
 
Upvote 0
The first thing I would try is just using the same code but reordering the code so that you only deal with one workbook at a time , ie. open the workbook , then determine the last row, then copy the data then close the workbook. then do the next workbook. This will save EXCEL needing to continually swap between workbooks on every step of your code.. Also it might reduce the amount of memory needed
Tried this approach. Processing time has nearly doubled. From 8-10 seconds to 16 seconds ?
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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
Back
Top