+ Reply to Thread
Results 1 to 8 of 8

Extract distinct text values with number of occurrences of each

Hybrid View

  1. #1
    Registered User
    Join Date
    02-01-2021
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    11

    Extract distinct text values with number of occurrences of each

    I am using Excel 2010 version. My workbook column B has different text values, some of which occur multiple times. I want to extract all distinct values in column G and number of occurrences of each of these values in column H. I need help for this task. I am also enclosing sample file for clarity.

    If I wish to determine distinct values based on two text columns, column B and column C, is it possible? What will be the modification in code for this job.
    Attached Files Attached Files
    Last edited by Prabhakar1; 02-03-2021 at 06:24 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Extract distinct text values with number of occurrences of each

    In g2:

    =IFERROR(INDEX(B:B,AGGREGATE(15,6,ROW($B$2:$B$26)/(COUNTIF(G$1:G1,$B$2:$B$26)=0),1)),"")

    and in H2:

    =IF(G2="","",COUNTIF(B:B,G2))

    Both copied down.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    02-01-2021
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Extract distinct text values with number of occurrences of each

    Thanks Glenn. The formulas worked fine on the sample worksheet. I have not tried yet on the actual workbook where there are about 2500 rows. I will define the range (B column) appropriately and try. I will let you know the results. Thank you so much !!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,795

    Re: Extract distinct text values with number of occurrences of each

    Welcome to the forum.

    Try:

    =IFERROR(INDEX($B$2:$B$26,MATCH(0,INDEX(COUNTIF($G$1:G1,$B$2:$B$26),0,0),0)),"")

    and:

    =IF(G2="","",COUNTIF($B$2:$B$26,G2))
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    02-01-2021
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Extract distinct text values with number of occurrences of each

    Thanks Ali. Both the formulas worked fine on the actual worksheet with about 2500 rows.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Extract distinct text values with number of occurrences of each

    The first formula may take a minute or two to work its way through 2500 rows, but it's far from excessive for such a formula.



    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

  7. #7
    Registered User
    Join Date
    02-01-2021
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Extract distinct text values with number of occurrences of each

    Hi Glenn, I tried the formulas on the actual worksheet and they worked fine. Thank you so much for your valued support.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Extract distinct text values with number of occurrences of each

    Great!

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

+ 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. Replies: 3
    Last Post: 01-13-2021, 06:33 PM
  2. Replies: 2
    Last Post: 11-23-2020, 12:03 PM
  3. Formula to extract unique values/distinct values in rows in excel
    By bjnockle in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-07-2020, 05:35 PM
  4. How-to: Extract, count and rank text occurrences
    By BijanK in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-16-2019, 12:10 PM
  5. Replies: 13
    Last Post: 08-28-2014, 08:00 PM
  6. [SOLVED] Compare 2 columns, extract duplicates and number of occurrences
    By vin1602 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-04-2013, 02:51 PM
  7. Replies: 4
    Last Post: 03-14-2012, 11:44 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