tags:

views:

70

answers:

1

Hello All,

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)

+2  A: 

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.

Charles Williams