Setting number of processor threads

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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)
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,291
Members
448,564
Latest member
ED38

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
Back
Top