+ Reply to Thread
Results 1 to 11 of 11

COUNTIF for really specific text strings

  1. #1
    Registered User
    Join Date
    01-28-2020
    Location
    London, England
    MS-Off Ver
    365
    Posts
    3

    COUNTIF for really specific text strings

    Hi all,

    I'm afraid I'm not a real Excel whizz so forgive me if I don't explain this well. I have a table that lists out our team projects and which staff are allocated to them. This can be one person or multiple separated by a comma and space. I then want to create a list of the team with a count next to their name of how many projects each person is on, but I have an issue in that two staff members have very similar names.

    If this is my range of five projects, how do I count how many projects Ann is assigned to?

    Ann
    Annalisa
    Dave, Ann
    Ann, Sarah
    Sarah

    If Ann is the reference cell at A1 I've tried...

    =COUNTIF(Range, "*" & A1 & "*")

    but that counts Annalisa as well so I get 4 instead if 3. If I try...

    =COUNTIF(Range, A1)

    that's exact match and I only get 1.

    Any ideas???

    Thanks!

  2. #2
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    266

    Re: COUNTIF for really specific text strings

    Hi,
    Instead of trying to explain it please attach a sheet with a mock-up of your expected result. Follow the yellow banner at the top.
    Cheers

    If i understand correctly you could try just =COUNTIF(Range,A1&"*")
    Last edited by JulianS96; 01-28-2020 at 01:17 PM.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: COUNTIF for really specific text strings

    The obvious first question is why is it necessary to capture the data in such a way?
    A more traditional approach, and certainly a more flexible and efficient approach would be to have two columns, one for the Project Reference and the second for the Person's name

    So in this example you would have 7 rows. Then using COUNTIF is trivial.

    However this is clearly a much simplified example and probably doesn't represent the size of your actual data. We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned.

    Therefore upload your real workbook (or at least a cut down copy), and manually add the results you expect to see. Clearly identify which is original data and which are the results and in a note clearly explain how you have arrived at your results.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: COUNTIF for really specific text strings

    Please Login or Register  to view this content.
    or array formula
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,829

    Re: COUNTIF for really specific text strings

    You could achieve the result you want by this formula:

    =SUM(COUNTIF(A1:A5,{"*, Ann","Ann, *","Ann"}))

    with your data in A1:A5.

    Hope this helps.

    Pete

  6. #6
    Registered User
    Join Date
    01-28-2020
    Location
    London, England
    MS-Off Ver
    365
    Posts
    3

    Re: COUNTIF for really specific text strings

    Thanks Pete! I did think of that, but that means I would have to type the names out for each of the 100+ team members. Do you know if there's a way to do that but substitute the actual word Ann for a cell reference, eg A1?

  7. #7
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    266

    Re: COUNTIF for really specific text strings

    Quote Originally Posted by JulianS96
    If i understand correctly you could try just
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Hopefully this helps However I think that BMV's solution is best.
    Last edited by JulianS96; 01-28-2020 at 01:20 PM.

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,829

    Re: COUNTIF for really specific text strings

    Wherever Ann appears in the formula (3 times) you can substitute A1 for it, but you would also need to adjust where the quotes are and add a solidus where necessary, i.e.:

    =SUM(COUNTIF(A$1:A$5,{"*, "&A1,A1&", *",A1}))

    Hope this helps.

    Pete

    EDIT: Forget that - you can't use a cell reference in a literal string.

    Pete
    Last edited by Pete_UK; 01-28-2020 at 01:23 PM.

  9. #9
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: COUNTIF for really specific text strings

    JulianS96, Pete_UK's solution useful also but both have some restrictions and depend on data and condition. As example if in stand of comma there will be dot or any other symbols the formulas must be changed.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: COUNTIF for really specific text strings

    I come back to my original question. If someone is typing in seven names some in the same cell why not just type the names in a row of their own. The adjacent Project reference could be a data validation drop down which avoids further typing.

    I never cease to be surprised that people complicate data enty from the start and then wonder down the line as their system develops why it becomes harder and harder to analyse it.

  11. #11
    Registered User
    Join Date
    01-28-2020
    Location
    London, England
    MS-Off Ver
    365
    Posts
    3

    Re: COUNTIF for really specific text strings

    HI Richard,

    Thanks for your reply. I'm afraid its not my template, its a company wide one so I have no power to change the format, I'm just a data entry drone in this situation trying to make my own life easier by automating a manual process within the formatting confines I've been given.

    Sam

+ 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. Swap Specific Text Strings in a Range and Indicate new Strings Not already in Code.
    By liquidmettle in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-17-2018, 01:31 PM
  2. Identify specific text strings in a cell?
    By mnidevil in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 12-18-2014, 01:55 PM
  3. Join Text Strings meeting specific criterias
    By esperanto in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-18-2013, 05:29 AM
  4. Replies: 5
    Last Post: 05-03-2011, 09:35 AM
  5. Vlookup or Countif using text strings
    By jrabrfc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-10-2009, 06:56 AM
  6. Replies: 5
    Last Post: 07-15-2009, 10:59 AM
  7. Identifying specific text strings in a range
    By steekvey in forum Excel General
    Replies: 2
    Last Post: 05-01-2008, 08:00 AM

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