Declare and Initialize String Array in VBA

Kairan picture Kairan · Oct 14, 2013 · Viewed 690.9k times · Source

This should work according to another stack overflow post but its not:

Dim arrWsNames As String() = {"Value1", "Value2"}

Can anyone let me know what is wrong?

Answer

Eldar Agalarov picture Eldar Agalarov · Oct 14, 2013

Try this:

Dim myarray As Variant
myarray = Array("Cat", "Dog", "Rabbit")