+ Reply to Thread
Results 1 to 8 of 8

How to count number of occurences of each element within array

  1. #1
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    How to count number of occurences of each element within array

    Hello to all,

    How to count the ocurrences of each element within array?

    For the sample array below, I'd like to store in an array or variables the number of a's, b's and c's, so the output would be:

    Number of a´s = 4
    Number of b´s = 1
    Number of c´s = 2

    Please Login or Register  to view this content.
    Thanks in advance

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to count number of occurences of each element within array

    This will count how many of a particular element is in an array
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to count number of occurences of each element within array

    The output is on active sheet A1.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: How to count number of occurences of each element within array

    Hello mikerickson,

    Thanks for your answer. I'm trying and it seems to work. I'll test it within my code that has many values.

    Hello AB33,

    Thanks for your help too. It works well too.

    One question,

    Your output shows each value in difderent row, how to print the values (items) in the same row?

    I've tried doing as below but is doesn't seem to be the best/direct way to do it.
    Please Login or Register  to view this content.
    Thanks again

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to count number of occurences of each element within array

    If mean you want to swap columns for rows.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: How to count number of occurences of each element within array

    Hello AB33,

    Thank you for your answer. I thought could be a more direct way to avoid the use of "transpose" twice, but I tried as below and doesn't work.
    Please Login or Register  to view this content.
    Thanks again.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to count number of occurences of each element within array

    You could use two lines if you want

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: How to count number of occurences of each element within array

    Hello AB33,

    In that way works perfect!.

    Thanks so much.

    Regards

+ 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. Count number of occurences
    By pedrotairum in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-03-2014, 03:45 AM
  2. Count the number of occurences of a value
    By therealjag in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2010, 06:25 AM
  3. count number of element
    By iscar_marius in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-19-2008, 10:45 AM
  4. [SOLVED] find the index number for an array element
    By Dick Minter in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-20-2006, 07:01 PM
  5. Replies: 0
    Last Post: 01-27-2006, 04:15 PM

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