Declare and Initialize String Array in VBA

In the specific case of a String array you could initialize the array using the Split Function as it returns a String array rather than a Variant array:

Dim arrWsNames() As String
arrWsNames = Split("Value1,Value2,Value3", ",")

This allows you to avoid using the Variant data type and preserve the desired type for arrWsNames.


Try this:

' Variant array    
Dim myVariantArray As Variant
myVariantArray = Array("Cat", "Dog", "Rabbit")

' String array
Dim myStringArray() As String
myStringArray = Split("Cat,Dog,Rabbit", ",")