Forum Discussion
Hershner04
Sep 22, 2021Copper Contributor
Excel Macro Runs *PAINFULLY* Slow
I have an issue running an Excel Macro. I have read a lot of threads and tried all of the suggestions but no change in performance. I have run the same file/macro on 2 machines, details below. No mat...
Hershner04
Sep 22, 2021Copper Contributor
Thank you for responding to my problem. The code is not the issue. Same file, same code on two different machines. Original machine has been consistently running 11 seconds per iteration. New machine, which by the specs is far superior, runs 24 seconds per iteration. Once I address the performance of the file, I might look to optimize the code based on my needs, but I’m not there quite yet.
Juliano-Petrukio
Sep 22, 2021Bronze Contributor
Well, optmization means take into consideration the code as well.
Refactoring a code its painfull sometimes, but its important reassess the approach and variables, etc. to achieve the same result considering different environments.
Also consider the machine settings (Memory, processor, OS versions, etc.)
I had problems in the past where my codes was running very slow, but after refactoring the code it was improved a lot.
As I told you, it depends of a lot of things consider review the code is a part of improvement too.
Refactoring a code its painfull sometimes, but its important reassess the approach and variables, etc. to achieve the same result considering different environments.
Also consider the machine settings (Memory, processor, OS versions, etc.)
I had problems in the past where my codes was running very slow, but after refactoring the code it was improved a lot.
As I told you, it depends of a lot of things consider review the code is a part of improvement too.
- Hershner04Sep 22, 2021Copper ContributorThank you for your consideration. I agree bad code can run poorly, but that is not the issue causing me pain.
My issue is that *the same* code and *the same* macro using *the same* dataset running on 2 different machines has disparate results. One is a 6 year old machine with half the cores/threads/RAM and an HHD, the other machine was assembled/built a little over 4 months ago and has twice as many cores/threads/RAM with an SSD. By all accounts it should run much faster but it is instead running much slower.
I know that everyone says it’s not their code, and I’m not that guy. I fully acknowledge the code is not optimized, but on my old machine it runs acceptably. On my new machine, the performance is unacceptable. Before I run down the rabbit hole of code optimization, I want to get to the bottom of the hardware/software issue that is causing my new machine to run at essentially half the speed.
As for code optimization, when I originally wrote the code 6 months ago, I did try several changes including turning off auto calculations and only running them as needed, turning off screen refresh, etc, etc.. and had very strange results there, too. My iteration time actually slowed down, so I reverted the change that made a difference (screen refresh). I have not run through the same exercise on the new machine, but I’m hesitant to do so until I address the performance issue.- Juliano-PetrukioSep 22, 2021Bronze Contributor32 bits or 64 Bits either for Windows and Office?
VBA codes from an older Excel version or other third‐party Active Xs, you could encounter all sorts of problems. This is because many Excel add‐ons are 32‐bit versions that are not fully compatible with the 64‐bit Excel.- Hershner04Sep 22, 2021Copper ContributorThanks for your response! My older machine has always been a 64-bit OS and Office 365 packages with an iteration speed of 11 seconds. My new machine was a 64-bit OS and 32-bit Office 365 package, but I have since uninstalled the 32-bit package and installed the 64-bit version. In both situations, the iteration time was the same (24 seconds). Both Office 365 installations are 16.0.
I have not checked Active X installations but I will do that tonight.