Why use arrays in VBA when there are collections?

Several reasons to use arrays instead of collections (or dictionaries):

  • you can transfer easily array to range (and vice-versa) with Range("A1:B12") = MyArray
  • collections can store only unique keys whereas arrays can store any value
  • collections have to store a couple (key, value) whereas you can store whatever in an array

See Chip Pearson’s article about arrays for a better understanding

A better question would rather be why people would use collections over dictionaries (ok, collections are standard VBA whereas you have to import dictionaries)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)