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

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.75 out of 5)
Loading...
Go back to All Questions Login or Register
235 views
0

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

0

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 VBA!

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match