Possible to use it more than 1 for loop? (MultipleThread via VBA)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Hi, I realize that the example given is only for 1 for loop. What if I need to use more than 1 for loop? Is it possible to make it?
For i = 1 to 10
for j = 1 to 10
for k = 1 to 1000
worksheets(i).cells(k, j) = i + j + k
next k
next j
next i

Thank you very much,
Yoof Chau


Hi Yoof,

if you want your results posted into your “master” workbook from all threads use the ParallelMethods.SaveRangeToMaster method which is coded based on the GetObject VBA method accessing the Excel master application worbook.

I would however not do this as you did in your example above as this would surely cause the processes to block, crash or slow down the execution (my best guess). Best way would be to save the results of each thread into an Array (3 D in your case) and then “dump” the entire Array in one go using the ParallelMethods.SaveRangeToMaster method.

Hope this helps.

Simply the best place to learn Excel VBA