Forum Discussion
Aless1275
Oct 15, 2021Copper Contributor
Create a routine to check the values of a row in a table and modify the ones of following row
Hi, and thanks for coming here. I'm trying to create a routine that does what the title says. I have a table where each row represents an hour of the year, to which certain quantities (indicated on...
- Oct 15, 2021
In TEST_check_prev_SOC, the line
Set mySh = Application.ThisWorkbook.Worksheets("Sheet1")
is superfluous - it has already been set in the calling macro TEST_SOC_logic.
And the line
Set focus_SOC = mySh.Range("D2")
resets focus_SOC to D2 each time after it has been changed in the calling macro.
So remove those two lines from TEST_check_prev_SOC
Aless1275
Oct 15, 2021Copper Contributor
okay perfect, thank you!
Now is working all fine, but for the all year it's taking quite a while to perform the simulation. To speed it up i could put at the beginning of the code (just after the variables initialisation):
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
and then just before the end of the main sub:
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
Is there something more that i can do to speed it up?
Now is working all fine, but for the all year it's taking quite a while to perform the simulation. To speed it up i could put at the beginning of the code (just after the variables initialisation):
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
and then just before the end of the main sub:
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
Is there something more that i can do to speed it up?
HansVogelaar
Oct 15, 2021MVP
Sometimes it helps to add
Application.Cursor = xlWait
at the beginning, and
Application.Cursor = xlDefault
at the end, but you'll have to test it.