View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How to find the Dimensions of a Variant Range

Try

Function GetDims(Arr() As Variant) As Long
Dim Ndx As Long: Ndx = 1
Dim SaveNdx As Long
Dim V As Variant
On Error Resume Next
Do Until Err.Number < 0
V = UBound(Arr, Ndx)
If Err.Number = 0 Then
SaveNdx = Ndx
Else
GetDims = SaveNdx
End If
Ndx = Ndx + 1
Loop
End Function

You can then call this as

Dim Dims As Long
Dims = GetDims(IRange)



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Frans Verhaar" wrote in message
...
I have a worksheet contains a named range referenced to cells
A1:C3 called InputRange
I read this range into a variant and then want the dimensions
of the variant.

Sub ReadRange()
Dim IRange() As Variant
IRange() = Range("InputRange")
End Sub

I tried but I can only find the vertical dimension with the
following: MsgBox UBound(IRange)
Can someone help me how to find the other dimension?

Thanks a lot on your ideas...

Frans