+ Reply to Thread
Results 1 to 14 of 14

Assistance with CountIF from a list

  1. #1
    Forum Contributor
    Join Date
    05-17-2012
    Location
    Silver Spring
    MS-Off Ver
    Excel 2016
    Posts
    212

    Assistance with CountIF from a list

    Currently I am using a bunch of OR(CountIF statements to search a column for words that begin with something. Ex:

    IF(OR(COUNTIF($Q2,"abc-"&"*"),COUNTIF($Q2,"def-"&"*"),COUNTIF($Q2,"ghi"&"*"),COUNTIF($Q2,"jkl-"&"*"),COUNTIF($Q2,"mno-"&"*"),COUNTIF($Q2,"pqr-"&"*"),COUNTIF($Q2,"stv-"&"*"),COUNTIF($Q2,"wzy-"&"*")),"Exempt","")

    Is there a way to use one CountIF but have it check through a list? so this way its less coding and in the event I have to another another one I can just add it to the list

    List Ex:
    abc-
    def-
    ghi-
    jkl-
    mno-
    qrs-
    tvu-
    wzy-

    The hard part of this is the letters start each word so I need to have it search the table for anything beginning with and can have a wild card after.
    Thank you

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Assistance with CountIF from a list

    List Ex: -> range A1:A10

    Try this ...

    =IF(MAX(COUNTIF($Q2,$A$1:$A$10&"*")),"Exempt","")

  3. #3
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Assistance with CountIF from a list

    Or ...

    =IF(OR(COUNTIF($Q2,{"abc-*","def-*","ghi*","jkl-*","mno-*","pqr-*","stv-*","wzy-*"})),"Exempt","")

  4. #4
    Forum Contributor
    Join Date
    05-17-2012
    Location
    Silver Spring
    MS-Off Ver
    Excel 2016
    Posts
    212

    Re: Assistance with CountIF from a list

    Unfortunately it didn't work.
    Here is my current code.

    =IF($G2="","",
    IF(MAX(COUNTIF($Q2,HelpDeskExempt!$A$1:$A$25 & "*")),"Exempt",
    IF(MAX(COUNTIF($K2,HelpDeskSubNets!$A$1:$A$50 & "*")),"Help Desk",
    "Other"))))

    Everything shows up as Other so the Except and Help Desk lines aren't working.
    Any suggestions?

  5. #5
    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,193

    Re: Assistance with CountIF from a list

    Try

    =SUM(COUNTIF(Q2,A1:A25 & "*"))

    Enter with Ctrl+Shift+Enter

    will return 1 if Q2 found in A1:A25

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Assistance with CountIF from a list

    You can change SUM to SUMPRODUCT so it doesn't require CTRL + SHIFT + ENTER

    And it's important that there are no blanks in the list (A1:A8)

    =IF(SUMPRODUCT(COUNTIF($Q2,$A$1:$A$8&"*")),"Exempt","")

  7. #7
    Forum Contributor
    Join Date
    05-17-2012
    Location
    Silver Spring
    MS-Off Ver
    Excel 2016
    Posts
    212

    Re: Assistance with CountIF from a list

    Testing...

  8. #8
    Forum Contributor
    Join Date
    05-17-2012
    Location
    Silver Spring
    MS-Off Ver
    Excel 2016
    Posts
    212

    Re: Assistance with CountIF from a list

    Ok Jon and John it worked, I did the SumProduct so I wouldn't have to make it an array. But its giving false results. Its saying except for items that are not on the list. I'm looking over it now to see if I can figure out what its doing wrong

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Assistance with CountIF from a list

    As I said in my post.

    It's IMPORTANT that there are NO BLANKS in the range with your list A1:A8

  10. #10
    Forum Contributor
    Join Date
    05-17-2012
    Location
    Silver Spring
    MS-Off Ver
    Excel 2016
    Posts
    212

    Re: Assistance with CountIF from a list

    Jonmo1 my apologies I missed that, reviewing now.

  11. #11
    Forum Contributor
    Join Date
    05-17-2012
    Location
    Silver Spring
    MS-Off Ver
    Excel 2016
    Posts
    212

    Re: Assistance with CountIF from a list

    Jonmo1, you were correct. I had a space at the end. By adjusting the range it corrected it. Thank you all very much for your assistance as it is now working.
    Jon, out of curiosity, why does that extra space throw it off?

  12. #12
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Assistance with CountIF from a list

    If one of the cells in A1:A8 is blank, then the countif for that blank cell translates to

    =COUNTIF($Q2,""&"*")
    =COUNTIF($Q2,"*")

    With that being a wildcard, it will consider any text value of Q2 as a match to "*"

  13. #13
    Forum Contributor
    Join Date
    05-17-2012
    Location
    Silver Spring
    MS-Off Ver
    Excel 2016
    Posts
    212

    Re: Assistance with CountIF from a list

    Makes complete sense, Thank you!

  14. #14
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Assistance with CountIF from a list

    You're welcome.

+ 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. Assistance needed with the COUNTIF/COUNTIFS function.
    By BiomedRoss in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-15-2015, 08:30 AM
  2. [SOLVED] COUNTIF assistance, factoring in weighting
    By ripcorder in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-18-2015, 08:46 AM
  3. Assistance with formula (countif,sum,index)
    By omv_80 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-30-2014, 11:20 AM
  4. Need assistance with production summary template. Countif error?
    By Mike.handle in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-18-2013, 02:42 PM
  5. Replies: 16
    Last Post: 01-26-2012, 07:02 PM
  6. Drop Down List Assistance
    By ajocius in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2009, 03:29 PM
  7. Tab list /summary assistance
    By mark_b2410 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-08-2008, 06:50 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