Setting number of processor threads

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,042
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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,042
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)
 

Forum statistics

Threads
1,176,402
Messages
5,902,850
Members
435,001
Latest member
ahsanali32

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