Hi All,
I'll try to make this as brief as possible, but please let me know if I haven't supplied enough info.
I have a project with approximately 19,000 lines of code (I'm assuming that's large but have no frame of reference). It has multiple buttons that launch subroutines to find specific data and display it in a way that allows it to be graphed easily. It has grown over time and worked fine until the last three subroutines I added. Those last three subroutines were only 30 lines of code each and only copy/pasted data to a new tab. However, after adding those EVERYTHING in the workbook slowed down considerably. What used to take 3 seconds now takes several minutes or more.
I fixed the subroutines by adding the following code to the beginning of each subroutine:
And the adding the following to the end of the subroutine:
That speeds up all of my subroutines, but here is the problem: Changing any cell in the workbook takes a ridiculous amount of time. If I turn of automatic calculations everything is fine, but my users won't know how to turn that on and off manually without causing problems.
How do I manage a workbook this size without sacrificing the speed of the calculations? I don't need the whole workbook to update every time a cell is changed but I do need to get the user accurate data. Does anyone have tips on how I can approach this? Am I even thinking about it in the right way? Any tips/advice are greatly appreciated!!!
I'll try to make this as brief as possible, but please let me know if I haven't supplied enough info.
I have a project with approximately 19,000 lines of code (I'm assuming that's large but have no frame of reference). It has multiple buttons that launch subroutines to find specific data and display it in a way that allows it to be graphed easily. It has grown over time and worked fine until the last three subroutines I added. Those last three subroutines were only 30 lines of code each and only copy/pasted data to a new tab. However, after adding those EVERYTHING in the workbook slowed down considerably. What used to take 3 seconds now takes several minutes or more.
I fixed the subroutines by adding the following code to the beginning of each subroutine:
Code:
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
And the adding the following to the end of the subroutine:
Code:
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
That speeds up all of my subroutines, but here is the problem: Changing any cell in the workbook takes a ridiculous amount of time. If I turn of automatic calculations everything is fine, but my users won't know how to turn that on and off manually without causing problems.
How do I manage a workbook this size without sacrificing the speed of the calculations? I don't need the whole workbook to update every time a cell is changed but I do need to get the user accurate data. Does anyone have tips on how I can approach this? Am I even thinking about it in the right way? Any tips/advice are greatly appreciated!!!