+ Reply to Thread
Results 1 to 3 of 3

Create 1-col array identifying occurrence count in a 1-col array

  1. #1
    Registered User
    Join Date
    08-03-2009
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    13

    Create 1-col array identifying occurrence count in a 1-col array

    Given a column array {a;b;a;c;a;d;b} I need a formula to give the result {1;1;2;1;3;1;2}
    I do not want to use a helper column.

    If the array occupies (A1:A7) the required result can be obtained in C1 to C7 by dragging
    =COUNTIF($A$1:A1,"="&A1)
    down from C1 to C7. But I want the result to be an array.

    The formula {=COUNTIF($A$1:$A$7,"="&$A$1:$A$7)} creates {$B$1:$B$7} as {3;2;3;1;3;1;2}

    I am trying to create arrays in cols. B and C which look like:
    a 3 1
    b 2 1
    a 3 2
    c 1 1
    a 3 3
    d 1 1
    b 2 2

    Does anyone know any clever tricks using INDEX, MATCH, COUNTIF, SMALL for example which might achieve this?
    Any suggestions would be appreciated, especially if they do not involve VBA

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Create 1-col array identifying occurrence count in a 1-col array

    Something like this, entered as an array formula in cells B1:B7 seems to work for me:

    =COUNTIF(A1:OFFSET(A1,ROW(A1:A7)-1,0),A1:A7)

  3. #3
    Registered User
    Join Date
    08-03-2009
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    13

    Re: Create 1-col array identifying occurrence count in a 1-col array

    Brilliant. Many Thanks! The OFFSET function is the key, and it hasn't been in my vocabulary.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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