array length in VBA

  • Thread starter Thread starter itsmaheshp
  • Start date Start date
I

itsmaheshp

Hai buddies,
i am having a array declaration like this

Code
-------------------

dim a(10) as Integer

-------------------


and it has some values say 1,4,2,5 ( only 4)
.Now i want to find the total no.of values in the array (i.e 4). i use
Ubound but it is giving me the total capacityof the array which i am n'
interested.
what is the function i have to use to find that.
thanks & regards,
mahes
 
You cant do this with an array that's declared as an integer,
(cause all the elements are 0) but you could it you'd declare it as a
variant.. (elements are initialized as empty)

Sub test()
Dim a(10) As Variant
Dim l As Long
a(3) = 4
'countA counts strings & numbers
'count counts numbers only
l = Application.CountA(a)
Stop

End Sub


maybe you'd be better served with using a collection object?





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


itsmaheshp wrote :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top