(Solved) – Evaluate string to array


I am using such a line so as to assign the variable a to an array and it works well

a = [{"From","To";1,2;2.5,3.5;3.5,5;5.7,7}]

Now I have this stored in a string

    s = "[{""From"",""To"";1,2;2.5,3.5;3.5,5;5.7,7}]"
a = Evaluate(s)

How can I return the array from the string itself? I tried using Evaluate but this throws an error

Sub Test()
Dim a
Dim s As String

s = "[{""From"",""To"";1,2;2.5,3.5;3.5,5;5.7,7}]"
a = Evaluate(s)

'a = [{"From","To";1,2;2.5,3.5;3.5,5;5.7,7}]

Range("A1").Resize(UBound(a, 1), UBound(a, 2)).Value = a
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *