Hi all,
Is there a particular reason why below code runs for 25 seconds? Can it be optimised somehow? The range aren't calculating anything, so far I have simply "added" them to the workbook...
![]()
Please Login or Register to view this content.
Hi all,
Is there a particular reason why below code runs for 25 seconds? Can it be optimised somehow? The range aren't calculating anything, so far I have simply "added" them to the workbook...
![]()
Please Login or Register to view this content.
Hi,
Why are you giving the same ranges two names?
FYI, I find it easier to use this syntax
and you may want to make calculation manual while you add the names and, if the TimePeriod_Analytics combobox is directly linked to a range using ListFillRange, you should probably use a flag variable to prevent recursion just in case.![]()
Please Login or Register to view this content.
Don
Please remember to mark your thread 'Solved' when appropriate.
Because if the fiscal year 2016 is selected in my form control combobox, I need last years data to refer to the same as this years data as 2015 data is unavailable.Why are you giving the same ranges two names?
Not sure what you mean by "flag variable"? My combobox cell link is the "Fiscal_Year_Analytics" range as defined in my code.and you may want to make calculation manual while you add the names and, if the TimePeriod_Analytics combobox is directly linked to a range using ListFillRange, you should probably use a flag variable to prevent recursion just in case.
I was referring to the list in the combobox- where does that come from?
Did you try turning calculation to manual to see if that speeds things up?
The list in the combobox is coming from my "Control" sheet, the cell highlighted in yellow = Worksheets("Control").Range("Fiscal_Year_Analytics")
Yup, just tried. If I use "Application.Calculation = xlCalculationManual" alone, it speeds it up to about 3-4 seconds (instead of 25 seconds). However previously I used my "optimise code" macro (see below) and it did not speed up anything...hmmDid you try turning calculation to manual to see if that speeds things up?
3-4 seconds isn't too bad, but not ideal, as I still need to add some code. But I assume there's no more room for speed improvement?
forum.PNG![]()
Please Login or Register to view this content.
Is the list for the combobox a named range or a static address? If it's named, is that a fixed address or a dynamic range?
it's a static address that doesn't change!
OK, then a flag variable probably wouldn't make any difference.
Your OptimizeCode_End code is wrong though- you should remove the red line
![]()
Please Login or Register to view this content.
But I need to turn automatic calculation back on at the end of the code??![]()
Please Login or Register to view this content.
Note the blue line preceding it
which already resets the calculation state to whatever it was before you started running your code, and is better practice than blindly setting it back to automatic.![]()
Please Login or Register to view this content.
Oops! Thanks for pointing that out! It's working now! I guess I have to live with the 3-4 seconds delay. Thanks for your help!
You're welcome.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks