Convert Variant to Array

  • Thread starter Thread starter Ripan
  • Start date Start date
R

Ripan

I have a VBA method that converts a range to an array (depending on th
types of the values in the cell, it is an array of double or o
string). As a result, the return of the function needs to be a variant
Once I have this variant, can convert it to an array because otherwise
I cannot index the values in the array (i.e. I get a subscript out o
range error when trying to access elements in the variant)

Thanks for any hel
 
I get a subscript out of range error when trying to access elements in the
variant

You won't if you treat the variant as containing a 2-dimensional array:

Sub a()
Dim VarArray As Variant
VarArray = Range("A1:A10").Value
MsgBox VarArray(1, 1)
MsgBox VarArray(2, 1)
End Sub
 
Back
Top