Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA on Excel only use one processor, how can I use more?

VBA is known to work on only one processor at the same time, so when I run a macro, Excel only uses 50% of CPU instead of totally (dual-core).

Is there a workaround to make VBA use both processors ?

Thanks.

like image 544
Antoine Turmel Avatar asked Dec 07 '25 10:12

Antoine Turmel


2 Answers

The answer is no unless you split the workload across multiple Excel instances and recombine the results at the end.

But the vast majority of cases of slow VBA execution can be speeded up by orders of magnitude:

  • switch off screen updating
  • set calculation to manual
  • read and write excel data using large ranges and variant arrays rather than cell-by-cell
  • look closely at the coding in VBA UDFs and bypass the VBE refresh bug
  • minimise the number of calls to the Excel object model
like image 178
Charles Williams Avatar answered Dec 09 '25 23:12

Charles Williams


You could split the problem up across multiple instances of Excel.Applications, that way you could do half in one copy of Excel and half in the other.

I've seen someone doing simulation work in Excel VBA using 8 cores. A bit of a pain to bring the results back together at the end, but it worked.

like image 35
steveo40 Avatar answered Dec 10 '25 00:12

steveo40



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!