View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default ParamArray debug anomaly

I think what you are trying to do with this -

Function foo10(ParamArray x())
z = UBound(x(0)(1))
End Function


is really -

Function foo10(ParamArray x())
z = UBound(Application.Index(x(0), 1))
End Function

or depending which dimension -

z = UBound(Application.Index(x(0), 2))

Regards,
Peter T



"Alan Beban" wrote in message
...
I have the following, with the first row of the range containing the
values 33,34,35,36. When I run the sub procedure the Locals window shows
in part as below, indicating that x(0)(1) is a Variant array, but I get
a "Subscript out of range" error message at the line of foo10,
z = UBound(x(0)(1). Can someone explain the apparent anomaly?

Thanks,
Alan Beban

Sub abtest5()
x = range("a51:d54")
y = foo10(x)
End Sub

Function foo10(ParamArray x())
z = UBound(x(0)(1))
End Function

x Variant(0 to 0)
x(0) Variant/Variant/Variant(1 to 4,1 to 4)
x(0)(1) Variant(1 to 4)
x(0)(1,1) 33 Variant/Double
x(0)(1,2) 34 Variant/Double
x(0)(1,3) 35 Variant/Double
x(0)(1,4) 36 Variant/Double