Excel 2007中的多线程 [英] multi thread in Excel 2007

查看:129
本文介绍了Excel 2007中的多线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是我的情况。

( 1)我正在使用Excel 2007

(2)我的电脑是英特尔双核。

(3)对于这个测试,宏非常简单,并在模块中定义。



声明Sub Sleep Libkernel32(ByVal dwMilliseconds As Long)



功能simple_macro()
睡眠1000
simple_macro =hello world
结束功能



(4)我在100中填写= simple_macro() x 100个单元格在工作表中。



(5)完成处理宏所需的时间与选项中是否启用或禁用多线程功能相同。它看起来像Excel调度程序正在评估单元格线性...



如果我的宏执行一些cpu密集型处理是可以理解的,但是您可以看到它是相当的简单,每个单元格独立于其他单元,因此应在几秒钟内完成。



您是否有任何建议来同时评估细胞? Excel 2007支持多线程吗? (例如在评估时充分利用多个CPU内核)

解决方案

尽管Excel 2007计算引擎支持多线程,但Excel VBA没有。



所以用VBA编写的用户定义的函数被Excel处理为不是线程安全。


I have a question/problem on running a macro with some level of concurrency in Excel 2007.

Here is my situation.
(1) I am using Excel 2007
(2) My PC is an Intel Dual-Core.
(3) For this test, macro is very simple and defined in a module.

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Function simple_macro() Sleep 1000 simple_macro = "hello world" End Function

(4) I fill "=simple_macro()" in 100 x 100 cells in a worksheet.

(5) The time it takes to finish processing the macro is the same whether I enable or disable multi-thread features in option. It looks like the Excel scheduler is evaluating cells linearly...

It is understandable if my macro was doing some cpu-intensive processing, but as you can see it is quite simple and each cell is independent of others, thus it should finish within few seconds.

Do you have any suggestions to evaluate cells concurrently? Does Excel 2007 support multi-threading? (e.g. fully utilizing multiple CPU cores when evaluating)

解决方案

Although the Excel 2007 calculation engine supports multithreading, Excel VBA does not.

So user defined functions written in VBA are treated as not threadsafe by Excel.

这篇关于Excel 2007中的多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆