Using More CPU Power when Calculating

Written by Allen Wyatt (last updated October 18, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


13

Geoff has noticed that when calculating, Excel's CPU usage peaks at 50%. He wonders if there is any way to break through this barrier. He has tried setting Application.MultiThreadedCalculation.ThreadCount to various values, and has been able to bend the 50% limit out to about 58%, but there is still a large amount of untapped processing power available.

One way to change how much of your system resources are devoted to a particular task (such as running Excel) is to modify the importance placed on the task by the operating system. You can do this by displaying the Task Manager, right-clicking the Excel.exe process, and then choosing Set Priority. (Excel.exe is found in the Details tab of Task Manager with Windows 8 and Windows 10.)You will see six priority options available; Excel.exe is most likely set at a "Normal" priority level. You can increase the resources allocated to Excel.exe by the operating system by choosing either "Above Normal" or "High."

Note that you could also choose "Realtime," but this choice is not recommended. Why? Because then Windows will give precedence to Excel.exe at the expense of every other process on your system, including those processes used by the operating system itself. Essentially, this setting means that absolutely nothing else on your system can interrupt Excel. Sounds great, right? It can actually be a recipe for disaster because if Excel goes into an infinite loop or it takes inordinately long to finish some task (such as calculating a huge workbook), your entire system could lock up and you would be forced to reboot it.

Running at Realtime priority can also starve other system processes and prevent necessary system maintenance. Fortunately, it's rare that Excel will hold the CPU very long, so in most cases there won't be any adverse side effects, but nobody should ever boost any process to Realtime priority that's not explicitly designed for it.

Even if you were to boost Excel's priority to Realtime, you might not be able to get more than 50% usage. This is especially true if your machine has multiple CPUs or a multi-core CPU. How your system utilizes those additional CPUs (real or virtual) depends on several factors, the most important being the way in which the program (in this case Excel) is programmed to take advantage of threading on multiple CPUs. (Fortunately modern versions of Excel take advantage of multithreading opportunities very nicely.)

If you want to know more about how Excel uses memory, you can find detailed information at this helpful page:

http://www.decisionmodels.com/memlimitsc.htm

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11056) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Text Prints as Bold, but Displays as Regular

What to do when text looks one way on the screen but prints a different way? This tip provides several different ...

Discover More

Accepting Only Formatting Changes

When you use Track Changes in a document, Word marks everything that changes. (Makes sense, huh?) If an editor makes a ...

Discover More

Detecting Errors in Conditional Formatting Formulas

If an error exists in a formula tucked inside a conditional format, you may never know it is there. There are ways to ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Measuring Efficiency of Formulas and Macros

As the limits on what you can store in Excel have increased, so has the need to consider how to make your workbooks and ...

Discover More

Converting PDF to Excel

Reports and other formal documents are often distributed in PDF format so that they can be read and printed on a variety ...

Discover More

Finding the Number of Significant Digits

When looking at a number, you may wonder how many significant digits it contains. The answer is not always an easy one, ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 3?

2022-11-01 15:37:30

J. Woolley

My Excel Toolbox has a new version of the SetPriority macro that is acceptable to Google Drive.
See https://sites.google.com/view/MyExcelToolbox/


2022-10-30 15:57:42

J. Woolley

I had to remove the SetPriority macro from My Excel Toolbox because Google Drive interpreted it as a virus. Here is a link to the text file SetPriority.txt:
https://drive.google.com/file/d/1_MOYBQ9mOtvCTKDztapOxDdlVewiaaWa/view


2022-10-30 14:34:48

J. Woolley

My Excel Toolbox includes a modified version of Ken Varley's SetPriority macro (see Figure 1 below) .
See https://sites.google.com/view/MyExcelToolbox/

Figure 1. 


2022-10-28 08:35:02

J. Woolley

@LydiaN
Use Win32_Process. There is no Win64_Process in \root\cimv2.


2022-10-27 04:43:26

Ken Varley

Lydia

Sorry, I don't know the answer to your question. I merely found a solution on Mr Excel & used it.

However, adding to Rons description above, after opening Task Manager, you need to select the DETAILS tab.
Then right-click Excel.
At that point, you can change the priorities as described above.

Using the Macro Solution ........

My suggestion to your question would be
1. Open Excel without the macro.
2. Then open Task Manager and check to see what the priority is set at.

I would expect it to be set at NORMAL.

Then
1. Add the 32bit macro below into your AUTO_OPEN macro.
2. Save Excel
3. Close Excel
4. Re-open Excel
5. Open Task Manager and check to see what the priority is set at.

If it is set at HIGH, then the 32bit has worked. Job done.

If it is still set on NORMAL, change it to the 64 bit macro: SAVE IT; Close it;
Re-open Excel, then check Task Manager to see what the priority is set at.

If it is set at HIGH, then job done.

Good luck


2022-10-26 16:42:32

LydiaN

I have 64-bit Windows and 64-bit Excel 365. Is this part of the SetPriority macro below ok for my use: Win32_Process? Or would this need to be changed to Win64_Process? The Win32_Process verbiage is also included in KTo's macro update on 9/29/2021 on the Mr. Excel forum.

I tried Googling to no avail and I'm not a macro user.

Thanks!


2018-12-19 18:21:53

Ron

Thanks for the update. You surprised me. As I said, I didn't think it could be done.


2018-12-19 06:15:25

Ken Varley

Answered my own question

I found the answer in Mr Excel, copied the code but had to add the DIMS . Then it worked.

The following code is activated from AUTO_OPEN when opening my Excel dashboard and gives a HIGHER PRIORITY to Excel from that point unless Excel is closed down again.

------------------------------------------------------------------------------

Sub SetPriority()
'copied from https://www.mrexcel.com/forum/excel-questions/438142-set-priority-shell-command-vba.html
'dim line added by kjv

Const ABOVE_NORMAL = 32768
Const HIGH = 128

Dim strComputer, objWMIService, colProcesses, objProcess

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'excel.exe'")
For Each objProcess In colProcesses
objProcess.SetPriority (HIGH)
Next

End Sub


2018-12-18 07:58:53

Ken Varley

Ron

Is there possibly a macro that could change the priority. It could be entered into Auto_open and therefore be invoked every time excel is used ?


2018-12-17 16:22:08

Ron

Ken:
AFIK, there is no way to permanently change process priority in WIndows (but I could be wrong). I do know that there are some utilities you can use to do that for example the free and paid versions of Process Lasso, https://bitsum.com/?discount=BITSUM-40-OFF

Geof:
I just realized you are probably maxing out 1 of 2 available cores in your computer. The simplest way to verify that is start task manager. Go to the Performance tab. There is a summary of your hardware. I expect one of the entries will say "Logical Processors: 2". Excel will be running one of the the 2 processors at full capacity.


2018-12-17 05:43:47

Ken Varley

I tried this, but after closing Excel and reopening, I found that it had returned to NORMAL priority.

As i use Excel for most things, I want it to remain as ABOVE NORMAL by default. can this be done ?


2018-12-16 15:42:21

Jim

I tried resetting the priority of my Surface Pro 3 as suggested in this tip...interestingly, when I increase the priority to AboveNormal and High, my benchmark of about 300 million calculations actually runs nearly the same or more slowly.


2018-12-15 06:27:56

Ron

Actually, you missed the easiest way to increase CPU Cycles. Turn on the option to allow "multi-threading".

This doesn't work all the time, but when it does it can be a big help. Modern computers pretty much all have either "multiple CPU's" and or 'hyperthreading" as well as "multi-tasking". For several years high end consumer computers were limited to 4 or 8 physical cores. Recently AMD released consumer chips with up to 32 physical cores, starting a new "core" race between them and Intel, the other chip maker.

The ultimate expression of "multiprocessing" in the consumer market are special dedicated "GPU" chips. This are the chips used on video addon cards. They can have thousands of cores! This is because displaying a picture on screen can depend on thousands of identical calculations that can be done all at the same time to improve video display performance.

The ultimate expression of industrial multiprocessing is the "super computer". They specialize in calculations that can be done in parallel (like weather forecasting/simulation), and they need LOTS of parallel calculations. For the last decade or more these super computers have been built of of thousands of high end consumer/business class computers. But lately, many super computers have started adding LOTS of "GPU's" because they are already explicitly designed to do parallel processing. So a single video card is equivalent to LOTS of standard computers.

Originally computers were built with a single "core", that could do only one "thing", one program, at a time. Programmers quickly recognized that meant that the computer was sitting idle ("twiddling it's thumbs") most of the time, waiting for new requests or even just waiting to read "stuff" it needs from the hard drive (which is infinitely slower than the CPU). So they added "mult-tasking". That means that you can ask the computer to do multiple things "at the same time" and it will schedule them to run one after the other every time the current task pauses. So it runs a piece of one program until it has to wait for a read request to the Hard Drive, then it will start the next task in its "queue".

Next, the simplest "brute force" fix to give a computer more CPU cycles to work with was to simply add another "core" to the chip" (or another chip). So now the computer could work on 2 or more things at the same time. This is called multi-processors.

Finally, with some more advanced programming, they were able to trick the core into thinking it was twins, so that the computer thinks that one physical core is two. This is called "hyperthreading".

The simplest example of all three concepts is a computer chip with 2 physical cores and hyperthreading. It can work on 4 separate tasks at exactly the same time. So this computer has "4 logical cores". Plus, using multi-tasking each of those 4 logical cores can run multiple tasks, rapidly interleaved.

Originally Excel was designed to run on the single core. Later they had to add a special option to tell excel that it is allowed to split it's work out among more than one logical core to work at the same time.

You can find this option in
File menu > Options command > Advanced option > Formulas section > Enable Multi-threaded calculation option
The simplest variation is to tell Excel to allow to use all of the logical processors on the computer.

The thing is that this option will not work all of the time. Some calculations have to be done in a single, logical "thread" of operations, one after the other. But some calculations can be split into separate threads to work all at the same time. But like most things in Windows, there often is more than one way to do specific things in Excel. Some excel commands force it to use a "single thread". But you can often use "newer" commands that know how to allow excel to split the underlying operation into multiple, parallel, threads. So you may have to "optimize" your formulas to use explicitly avoid using single threaded commands.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.