Let's say I have something like "1-34-52"
, I want to split them into an array, however, while Test1 works, it gives me an String()
type array. How do I put the numbers in "1-34-52"
into a Long()
type array? Can I redim
type of an array in VBA?
Sub Test1()
Dim arr As Variant
arr = Split("1-34-52", "-")
Debug.Print TypeName(arr), TypeName(arr(0))
End Sub
Sub Test2()
Dim arr() As Long
arr = Split("1-34-52") 'You get type mismatch error
End Sub