+ Reply to Thread
Results 1 to 6 of 6

Dynamic count

  1. #1
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Dynamic count

    Suppose I have a column with recurring entries and I want to dynamically count the number of times the entry is present, what is the best way to do it?
    For example, if I have John in A2, A5 and A7, B2,B5 and B7 should read 1,2 and 3 respectively.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Dynamic count

    Do you only want to count when they appear together on the same row like this:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    1
    2
    John John
    1
    3
    4
    5
    John John
    2
    6
    7
    John John
    3
    Sheet: Sheet1

    Or something else?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Dynamic count

    A B
    1 Name Count
    2 John =COUNTIF($A$2:$A2,$A2)
    3 Andy =COUNTIF($A$2:$A3,$A3)
    4 Bill =COUNTIF($A$2:$A4,$A4)
    5 John =COUNTIF($A$2:$A5,$A5)
    6 Charlie =COUNTIF($A$2:$A6,$A6)
    7 John =COUNTIF($A$2:$A7,$A7)


    Which gives:
    A B
    1 Name Count
    2 John 1
    3 Andy 1
    4 Bill 1
    5 John 2
    6 Charlie 1
    7 John 3
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,328

    Re: Dynamic count

    Try

    Assuming data starts in A2 and column A is list of names


    =COUNTIF($A$2:A2,A2)

    This will increment count for a given name each time it is matched.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Dynamic count

    Try this:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    1
    2
    John John
    1
    3
    4
    5
    John John
    2
    6
    7
    John John
    3
    Sheet: Sheet1

    Excel 2016 (Windows) 32 bit
    C
    1
    =IF(A1<>B1,"",IF(COUNTIFS(A$1:A1,A1,B$1:B1,B1)=0,"",COUNTIFS(A$1:A1,A1,B$1:B1,B1)))
    Sheet: Sheet1

  6. #6
    Registered User
    Join Date
    07-11-2017
    Location
    Landau
    MS-Off Ver
    2010
    Posts
    47

    Re: Dynamic count

    Thank you for your responses! All of them work fine.
    I figured out my folly. I'm using my excel in English on a German PC.
    Needed to use the semi colon instead of the comma in the formulas!

+ 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] Need help with count with dynamic range
    By MoldyBread in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-25-2017, 10:15 PM
  2. Dynamic increase of row count
    By mohansingh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2015, 09:34 AM
  3. [SOLVED] Using 'Count If' with Dynamic Range
    By Dynamo418 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-05-2013, 03:07 PM
  4. Count Dynamic Row
    By aaanenson in forum Excel General
    Replies: 1
    Last Post: 07-18-2012, 06:16 PM
  5. Dynamic Date Count
    By Staggers72 in forum Excel General
    Replies: 0
    Last Post: 06-16-2011, 11:57 AM
  6. Dynamic range with count ?
    By vumian in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-22-2008, 06:28 AM
  7. [SOLVED] I would like to count # of occurences but have it be dynamic when.
    By Sifedirector in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-19-2005, 11:06 AM

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