Reputation: 85
I have a variable defined in string as below
Dim stringValue As String
Dim stringArray As String
stringValue = "3,4,5"
stringArray = Split(stringValue,",")
I am not sure what is going wrong here, but the when it goes through the Split function, it gives out
error ["Type error 13, Mismatch type"]
Upvotes: 0
Views: 290
Reputation: 11755
You want to define your stringArray
as a Variant
, so that it can take on the properties of an array.
Dim stringValue As String
Dim stringArray As Variant
stringValue = "3,4,5"
stringArray = Split(stringValue,",")
or define it as a string array from the start:
Dim stringValue As String
Dim stringArray() As String
stringValue = "3,4,5"
stringArray = Split(stringValue,",")
and for that matter, since your example is so simple, you could also do it like this:
Dim stringArray As Variant
stringArray = Array("3", "4", "5")
Upvotes: 2