+ Reply to Thread
Results 1 to 4 of 4

Counting elements in an array

  1. #1
    Registered User
    Join Date
    10-25-2006
    Posts
    54

    Counting elements in an array

    Hi

    Is it possible to count the number of elements I have in an array programatically?

    The array is within a vba module but and the count is used in several places. The count is assigned to a variable but I'd like the count to be dynamic in case someone adds an element but doesn't change the counter.

    Thanks

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    You can use UBound to determine the upper bound number of elements. Keep in mind that it starts with 0, so if you want actual number of elements (assuming you are not using Option Base 1), you wound need to use:

    Please Login or Register  to view this content.
    HTH

    Jason

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    If you use both LBound and UBound you do not have to worry about what values were used.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    10-25-2006
    Posts
    54
    wicked!

    Thanks guys.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1