+ Reply to Thread
Results 1 to 2 of 2

Quick Question! Count Elements in 1D or 2D array

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Quick Question! Count Elements in 1D or 2D array

    I know I can get the no. of elements in a 1D array by going (rough demo below)

    Please Login or Register  to view this content.
    and you can do a variation on the above for 2D arrays.

    Isn't there another more efficient way to count the total no. of elements in a 1D or 2D array?
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Quick Question! Count Elements in 1D or 2D array

    Hello mc84excel,

    You could use a loop to count the individual elements in the array. However, it would be more efficient to use LBound and UBound to calculate the array size.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Removing specific elements from an Array based on matching elements in a different Array
    By jamesdeuce in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2014, 10:35 PM
  2. [SOLVED] Quick Array question - Copy array to another array then resize?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-02-2013, 01:17 AM
  3. Count all elements in first dimension of an array that are equal to one?
    By Surreall in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-23-2013, 12:40 PM
  4. Count elements in Array
    By Rodas in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-08-2009, 02:20 PM
  5. [SOLVED] Count elements in array
    By Jason Morin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2005, 06:06 PM

Tags for this Thread

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