![]() |
array length in VBA
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 -- itsmahesh ----------------------------------------------------------------------- itsmaheshp's Profile: http://www.excelforum.com/member.php...fo&userid=1585 View this thread: http://www.excelforum.com/showthread.php?threadid=27655 |
array length in VBA
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 : 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 used Ubound but it is giving me the total capacityof the array which i am n't interested. what is the function i have to use to find that. thanks & regards, mahesh |
All times are GMT +1. The time now is 05:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com