Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge two collections in VBA?

What's the most efficient way to merge two collections together in VBA, so that I have a 3rd Collection containing all of the items from the first two?

like image 370
Greedo Avatar asked Dec 11 '17 16:12

Greedo


1 Answers

Read this article, which compares For vs For Each loops when iterating arrays, vs. when iterating object collections.

Bottom line:

  • Use For loops to iterate arrays.
  • Use For Each loops to iterate collections.

So, iterate your collections with For Each loops, and in these loops Add the items to your 3rd collection.

like image 189
Mathieu Guindon Avatar answered Nov 14 '22 22:11

Mathieu Guindon