Hi,
Range.Value returns:
- an array of variant if several cells,
- but a single value of the type of the data in the cell if only a single cell.
(you can see it by displaying Typename(rg.value))
Therefore trying to assign a single value to a full array fails.
In this case, force the assignment to an array element and not the full array:
Dim MyExt(), s
Dim rg As Range, rg2 As Range
Set rg = Range("a32")
Set rg2 = Range(rg, rg.EntireColumn.Cells(65536).End(xlUp))
If rg2.Cells.Count = 1 Then
ReDim MyExt(0 To 0)
MyExt(0) = rg2.Value
Else
MyExt = Range(rg, rg.EntireColumn.Cells(65536).End(xlUp)).Value
End If
For Each s In MyExt
Debug.Print ">" & s
Next
Regards,
Sebastien