JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,687
- Office Version
- 365
- Platform
- Windows
This test code gets passed a range, like "B2:R3". It works fine unless it gets passed a range of length 1, like "B3:B3". Then it gets an error because VBA stupidly makes "B3:B3" a scalar and not a one-dimensional array of length 1. "B3" is a scalar. "B3:B3" is a vector.
Ok, enough ranting.
What do I need to do to this code so that aTemp will be a one-dimensional array of length 1 if passed "B3:B3"?
Thanks
Ok, enough ranting.
What do I need to do to this code so that aTemp will be a one-dimensional array of length 1 if passed "B3:B3"?
VBA Code:
Function TestRng(rnTest As String)
Dim i As Long
Dim aTemp As Variant
aTemp = Range(rnTest).Value2
For i = 1 To UBound(aTemp)
Debug.Print aTemp(i)
Next i
End Function
Thanks