Setting number of processor threads

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,008
I'm using the following piece of code to toggle between a single processor doing a long calculation on a dual core PC and both processors doing it. The reason is that the calculations can be 10-20mins and I can do other things if I switch to 1 (i.e. surf the web or work on Access)

Code:
    application.GenerateTableRefs = xlGenerateTableRefStruct
    If application.MultiThreadedCalculation.ThreadCount = 1 Then
        application.MultiThreadedCalculation.ThreadCount = xlThreadModeAutomatic
    Else
        application.MultiThreadedCalculation.ThreadMode = 1
    End If

However it doesn't like the automatic setting (xlThreadModeAutomatic = 0). It works fine if I set the threadcount to 2, but I'd like it to be automatically scaleable for more processors.

According to Xl2007 Help it should work fine, any ideas?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,008
Fixed, with

Code:
    application.GenerateTableRefs = xlGenerateTableRefStruct
    application.MultiThreadedCalculation.Enabled = Not application.MultiThreadedCalculation.Enabled
    If application.MultiThreadedCalculation.Enabled Then application.MultiThreadedCalculation.ThreadMode = xlThreadModeAutomatic

it seems quite happy with the automatic setting now, odd (or maybe I just don't understand it properly)
 

Watch MrExcel Video

Forum statistics

Threads
1,133,579
Messages
5,659,629
Members
418,517
Latest member
LordWiader

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top