Hi,
I am trying to pass cell contents into an array. However, I can't seem to get the code to work if the range contains only one cell.
This is my code:
[vba]
Dim MyArray as Variant
' Read the data into the variant
MyArray = Range("A1:A2").Value
MsgBox UBound(MyArray)
[/vba]
However, the same code will fail if the range contains only one cell:
[vba]
Dim MyArray as Variant
' Read the data into the variant
MyArray = Range("A1").Value
MsgBox UBound(MyArray)
[/vba]
Please kindly advise what is wrong with my code. Thank you.
Reason of Edit: Code amendment