Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel VBA equivalent of a vector

Tags:

excel

vba

Does Excel VBA have a data structure equivalent of the vector?

I am still learning Excel VBA and do not like the ReDim Preserve semantics. But if that is the only way, then so be it.

So does Excel VBA 2003 provide a dynamic list type data structure?

like image 259
czchlong Avatar asked Oct 30 '12 14:10

czchlong


People also ask

What is an array in VBA?

An array is a single variable with many compartments to store values, while a typical variable has only one storage compartment in which it can store only one value. Refer to the array as a whole when you want to refer to all the values it holds, or you can refer to its individual elements.

What is a variant array VBA?

Arrays are a variant type variable that you can use in VBA coding to store a list of data. Think of it as a mini-spreadsheet inside of a single variable. You store data into an array by referring to a reference number that corresponds with the location that the piece of data is positioned in.

How do I create a dynamic array in VBA?

Create a Dynamic Array in VBAFirst, declare an array with its name. After that, the elements count left the parentheses empty. Now, use the ReDim statement. In the end, specify the count of elements you want to add to the array.


1 Answers

A simple sequential list-datatype would be Collection. Besides, an associative array is available via CreateObject("Scripting.Dictionary").

Dim c As Collection
Set c = New Collection
c.Add 4
like image 137
KekuSemau Avatar answered Oct 24 '22 23:10

KekuSemau