ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   returning number of subscripts? MyVar(x) (https://www.excelbanter.com/excel-programming/303228-returning-number-subscripts-myvar-x.html)

Jason[_32_]

returning number of subscripts? MyVar(x)
 
With MyVar(x),

x being unknown.

Is their a method to find x?

Jason



Bob Phillips[_6_]

returning number of subscripts? MyVar(x)
 
Jason,

The question is unclear. x is a variable in this case, which must have been
set within the code and you can query it

MsgBox x

Debug.Print x

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jason" wrote in message
...
With MyVar(x),

x being unknown.

Is their a method to find x?

Jason





Dave Peterson[_3_]

returning number of subscripts? MyVar(x)
 
Are you looking for the largest index for that array?
msgbox ubound(myVar)



Jason wrote:

With MyVar(x),

x being unknown.

Is their a method to find x?

Jason


--

Dave Peterson


Rob van Gelder[_4_]

returning number of subscripts? MyVar(x)
 
Are you trying to get the index in an array?

Example:


Sub test()
Dim arr() As Long, i As Long, blnFound As Boolean, lngFind As Long

ReDim arr(1 To 100)
For i = 1 To 100
arr(i) = i * 5
Next


'' find

lngFind = 50
blnFound = False
For i = LBound(arr) To UBound(arr)
If arr(i) = lngFind Then
blnFound = True
Exit For
End If
Next

If blnFound Then
MsgBox i
End If

End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Jason" wrote in message
...
With MyVar(x),

x being unknown.

Is their a method to find x?

Jason






All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com