excel运行vba_运行VBA功能时如何限制Microsoft Excel的CPU使用率?
excel运行vba
If you have a VBA function that turns Microsoft Excel into a CPU munching beast, is it possible to tame things down so that you can continue to use your computer for other activities while Excel is finishing up? Today’s SuperUser Q&A post comes to the rescue to help a frustrated reader get Excel back under control.
如果您具有将Microsoft Excel变成CPU咀嚼野兽的VBA功能,是否可以驯服某些东西,以便在Excel完成时可以继续将计算机用于其他活动? 今天的SuperUser Q&A帖子可以帮助沮丧的读者使Excel恢复正常。
Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.
今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。
Alien warrior clip art courtesy of Clker.com.
外来战士剪贴画由 Clker.com提供 。
问题 (The Question)
SuperUser reader learningAsIGo wants to know if there is a way to limit Microsoft Excel’s CPU usage while running a VBA script on his computer:
超级用户读者的学习AsIGo想知道是否有一种方法可以在计算机上运行VBA脚本时限制Microsoft Excel的CPU使用率:
Is there a way to limit Microsoft Excel’s CPU usage when it is running? I have a VBA script that calculates a large amount of giant array formulas. The entire set of calculations takes approximately twenty minutes to complete and uses 100 percent of my CPU. I am unable to use my computer during this time and would rather have Excel ‘running in the background’ while using about 50 percent of my CPU’s capacity so that I can continue to do other things.
有没有办法限制Microsoft Excel在运行时的CPU使用率? 我有一个VBA脚本,可以计算大量的巨型数组公式。 整个计算过程大约需要20分钟,并且会占用我100%的CPU。 我在这段时间内无法使用计算机,而是希望Excel在后台运行时使用大约50%的CPU容量,以便我可以继续执行其他操作。
Any suggestions? My computer’s operating system is Windows 7 Enterprise 64-bit with a 2007 32-bit version of Excel installed on it.
有什么建议? 我的计算机的操作系统是Windows 7 Enterprise 64位,上面安装了2007 32位版本的Excel。
Is there a way to limit Microsoft Excel’s CPU usage while running VBA functions?
在运行VBA功能时,是否可以限制Microsoft Excel的CPU使用率?
答案 (The Answer)
SuperUser contributor mtone has the answer for us:
超级用户贡献者mtone为我们提供了答案:
If a VBA function is called from several formulas or if your script generates or forces the recalculation of several formulas, then this should definitely make use of the multi-threaded calculation feature in Microsoft Excel. Respectively, this would either run multiple instances of your VBA function for each formula, or recalculate multiple cells simultaneously while your VBA script is running on a single thread.
如果从多个公式调用了VBA函数,或者您的脚本生成或强制重新计算了多个公式,那么这绝对应该利用Microsoft Excel中的多线程计算功能。 分别地,这将为每个公式运行VBA函数的多个实例,或者在VBA脚本在单个线程上运行时同时重新计算多个单元格。
You can limit the number of threads used by Excel to recalculate formulas by going to Options and selecting the Advanced Section, then scrolling down until you reach the Formulas sub-section.
您可以通过转到“ 选项”并选择“ 高级”部分 ,然后向下滚动直到到达“ 公式”子部分 ,来限制Excel用于重新计算公式的线程数。
![]()
Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.
有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程 。
excel运行vba