Why does a variant with a single value type convert to string?
I have filtered a list in another sub function, and then I want to parse out the values in column A. It works fine if there are multiple values, but when the variant "temp" has only one item, it becomes a string and I get Type Errors when it gets to the For/Next loop.
I tried to force it back to a variant with the red code, but it still comes out as a string!
Private Function assignTime()
Dim Lrow As Long
Dim temp As Variant
Dim Value As Variant
ReDim temp(0)
With Worksheets("Sheet2") 'Find last cell
Lrow = .range("A" & Rows.Count).End(xlUp).Row
temp = .range("A3:A" & Lrow).Value 'temp contains all values in A
End With
If TypeName(temp) = "String" Then
temp = CVar(temp)
End If
For Each Value In temp
'Parse a bunch of stuff
next value
end function
Bookmarks