Range to Array
"Gary''s Student" skrev i en
meddelelse ...
Why does:
Sub qwerty()
Dim r As Range
Dim v()
Set r = Range("A1:A2")
v = r.Value
End Sub
work just fine, but:
Sub qwerty()
Dim r As Range
Dim v()
Set r = Range("A1:A1")
v = r.Value
End Sub
raise a type mismatch error?
--
Gary''s Student - gsnu200727
Hi
Because you have defined v() as an array,
and Range("A1:A1") only contains one cell,
so v=r.Value will return the type mismatch error,
because Excel doesn't consider v an array in
this situation.
If you had Dim v
it would work in both instances, but in the first
instance v would be an array, while v in the second
instance is a variant variable!
--
Best regards
Leo Heuser
Followup to newsgroup only please.
|