Hi everybody !
I'm opening this thread because i need some help to make one of my application work better. I'm not new to VBA but i have no formation on programming and performance design. I'm pretty sure some of you have come across this type of questions and performance problem. Maybe you could give me some hint on the design. So here is the case :
My application import a table in a sheet than contain 400+ cost centers and information about it that i use to build a report. Those reports need to be grouped by cost center director (70) and saved in a distinct workbook (later emailed to them but it's a different process).
Here is how my the report creation process works:
1. Loop in a named range to create the 70 temporary workbooks and store it in a dictionary
2. On the report sheet, there is a single cell to change (the cost center number) and it change the whole report. So i loop by changing this cell based on a named range containing cost center number.
3. For every cost center number, make a copy using the .rows method (because i need to keep different rows height) on the clipboard then
4. Loop through the dictionary/workbooks to find the corresponding workbook, create a new sheet and paste.
5. Some copy/paste for shape or other object not pasted in #4
6. At the end, loop again in dictionary/workbooks and save each of them.
Everything works fine, except that for steps #2, #3, #4 , it takes more than a hour to process...
Note : I tried this with the same performance results : Create a temporary workbook, loop and create 400+ sheets/reports in it, loop through newly created sheet and copy (copy sheet method) the sheet with same director in a new workbook and save. Very long to process again.
Hope one of you have some ideas or something i should read to improve my coding.
Thanks,
I'm opening this thread because i need some help to make one of my application work better. I'm not new to VBA but i have no formation on programming and performance design. I'm pretty sure some of you have come across this type of questions and performance problem. Maybe you could give me some hint on the design. So here is the case :
My application import a table in a sheet than contain 400+ cost centers and information about it that i use to build a report. Those reports need to be grouped by cost center director (70) and saved in a distinct workbook (later emailed to them but it's a different process).
Here is how my the report creation process works:
1. Loop in a named range to create the 70 temporary workbooks and store it in a dictionary
2. On the report sheet, there is a single cell to change (the cost center number) and it change the whole report. So i loop by changing this cell based on a named range containing cost center number.
3. For every cost center number, make a copy using the .rows method (because i need to keep different rows height) on the clipboard then
4. Loop through the dictionary/workbooks to find the corresponding workbook, create a new sheet and paste.
5. Some copy/paste for shape or other object not pasted in #4
6. At the end, loop again in dictionary/workbooks and save each of them.
Everything works fine, except that for steps #2, #3, #4 , it takes more than a hour to process...
Note : I tried this with the same performance results : Create a temporary workbook, loop and create 400+ sheets/reports in it, loop through newly created sheet and copy (copy sheet method) the sheet with same director in a new workbook and save. Very long to process again.
Hope one of you have some ideas or something i should read to improve my coding.
Thanks,