+ Reply to Thread
Results 1 to 36 of 36

Is Countif the correct function to match a substring in a range to a selected value

  1. #1
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Is Countif the correct function to match a substring in a range to a selected value

    Hi,

    I have a working formula
    Please Login or Register  to view this content.

    Now the formula works when a cell in column OC in worksheet OfferDetails (which is what the named range Offerinoc refers to) has just one value - example - 685-cf-18A .
    So if rngOC = 685-cf-18A , the formula works.
    If it has say, three , 685-cf-18A ,685-cf-24b, 685-cf-11c then it doesn't work.

    I need to be able to match one of these three to rngOC.


    Please Login or Register  to view this content.
    by replacing Offerinoc=rngOC with (IF(COUNTIF(Offerinoc, "*"&rngOC&"*")>0,rngOC)=rngOC

    Also tried
    Please Login or Register  to view this content.
    but the cell remains blank.

    I dont know if i am using the wrong function -countif ?

    What could be the error. Would very much be grateful for help !

    thanks.
    anandi
    Last edited by anandis; 08-02-2020 at 01:14 PM. Reason: missing info

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    11,127

    Re: Is Countif the correct function to match a substring in a range to a selected value

    The first two formula boxes are empty.
    Post a sample file.


    (How to) Upload a Workbook directly to the Forum
    (please do not post pictures or links to worksheets)
    • Click Advanced next to "Post Quick Reply" button at the bottom right of the editor box.
    • Scroll down until you see "Manage Attachments",
    • Click the "Choose" button at the upper left (upload from your computer).
    • Select your file, click "open", click "upload"
    • Once the upload is completed the file name will appear below the input boxes in this window.
    • Close the Attachment Manager window.
    • Click "Submit Reply"
    Note: Please do not attach password protected workbooks/worksheets
    Ensure to disable any Workbook Open/Autorun macros before attaching!
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    I'm having a problem trying to upload an excel file . I keep getting a blocked error. The original code had SMALL(IF(Offerinoc=rngOC ,......

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    6,749

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Your IF is returning FALSE (=0) and becomming the smallest one

    SMALL(IF(Offerinoc=rngOC ,......,"")

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    42,133

    Re: Is Countif the correct function to match a substring in a range to a selected value

    What blocked error? Are you trying to post a link? That won't be allowed for you.

    Follow the instructions in post #2.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  6. #6
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    I wasnt trying to post a link but the excel sheet. But even if i try to add code i get this message : Access Denied - Sucuri Website Firewall

    I have also sent a message to the link on Contact Us with the entire error message.

  7. #7
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    ORIGINAL CODE - IFERROR(INDEX(OfferDetails[#Data],SMALL(IF(IF(COUNTIF(Offerinoc, "*"&rngOC&"*")>0,rngOC)=rngOC,ROW(OfferDetails[#Data])-ROW(OfferDetails[#Headers])), ROW(1:1)), MATCH($E$14, OfferDetails[#Headers], 0)),"")

    REVISED BUT NOT WORKING CODE - IFERROR(INDEX(OfferDetails[#Data],SMALL(IF(COUNTIF(Offerinoc, "*"&rngOC&"*")>0,rngOC),ROW(OfferDetails[#Data])-ROW(OfferDetails[#Headers])), ROW(1:1)), MATCH($E$14, OfferDetails[#Headers], 0)),"")

  8. #8
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Sorry I am having a lot of problems trying to post code. I just was able to repost both my original code snippet ( which is working fine) and the code where a value has to be matched to a record where it is present along with other values is giving me a lot of problems .

  9. #9
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    13,764

    Re: Is Countif the correct function to match a substring in a range to a selected value

    I wasnt trying to post a link but the excel sheet. But even if i try to add code i get this message : Access Denied - Sucuri Website Firewall
    That is a wellknow problem, which accurs once in a while.

    I had the same problem a while ago.

    To my opinion there is no other option, then to wait the forum solved the problem for you.
    Last edited by oeldere; 08-03-2020 at 11:12 AM. Reason: again in ago
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    6,749

    Re: Is Countif the correct function to match a substring in a range to a selected value

    To avoid firewall, anywhere with "larger" or "smaller", try " > " (with space before and after)
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Unfortunately this didnt work.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    42,133

    Re: Is Countif the correct function to match a substring in a range to a selected value

    If you are unable to attach the code to your post, then attach a workbook instead with the code in it

  13. #13
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    I tried that too. Still same problem .

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    42,133

    Re: Is Countif the correct function to match a substring in a range to a selected value

    You can't as a new member post a link. You need to follow the instructions at the top of the page. Try again, please.

  15. #15
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    13,764

    Re: Is Countif the correct function to match a substring in a range to a selected value

    AliGW

    OP said

    I wasnt trying to post a link but the excel sheet. But even if i try to add code i get this message : Access Denied - Sucuri Website Firewall
    I had this problem a while ago and had to wait the "moderators" solved that problem.

  16. #16
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    So trying to upload my original post as an image. Hope it is visible! I really really need help to solve this ! Thanks.

    excel.jpg

  17. #17
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    6,749

    Re: Is Countif the correct function to match a substring in a range to a selected value

    No It does not help!. Try to read instruction in upper yellow banner of the page to know how to attach a WS

  18. #18
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16
    Quote Originally Posted by bebo021999 View Post
    No It does not help!. Try to read instruction in upper yellow banner of the page to know how to attach a WS
    I've tried but in vain. I keep getting the same block error. That's why I posted the image.

  19. #19
    Forum Guru
    Join Date
    05-24-2011
    Location
    Kuwait
    MS-Off Ver
    Office 365
    Posts
    2,199

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Hello Anandi,

    Try this way:

    Replace Offerinoc=rngOC in IF formula to;

    ISNUMBER(SEARCH(rngOC,Offerinoc))
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    42,133

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Are you able to attach a .txt file containing the code? It is not usual for an attachment to trigger the Sucuri firewall - maybe itís to do with the name of the file?

  21. #21
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Can you see the attached text file?
    I have copied my original post in there.
    Attached Files Attached Files
    Last edited by AliGW; 08-04-2020 at 02:27 AM. Reason: Please don't quote unnecessarily!

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    42,133

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Yes, thanks. This will help.

    I still don't understand why you cannot attach the Excel workbook, though - what is the name of the file? Can you change it to simply 'test' and try attaching again?

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    42,133

    Re: Is Countif the correct function to match a substring in a range to a selected value

    If you remove IFERROR from your formulae, what error message do you get? Is it #N/A!, #VALUE! or something else?

  24. #24
    Forum Guru
    Join Date
    05-24-2011
    Location
    Kuwait
    MS-Off Ver
    Office 365
    Posts
    2,199

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Anandis,

    Did you try as I suggested in my previous post?

  25. #25
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Hi,

    So the first modified option , without IFERROR, returns the first value in the named range . The second option returns #NUM!

    Thanks.
    Last edited by AliGW; 08-04-2020 at 03:02 AM. Reason: Please don't quote unnecessarily!

  26. #26
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    42,133

    Re: Is Countif the correct function to match a substring in a range to a selected value

    OK. Have you tried attaching the workbook again as I suggested above? We really need to see it. If you can't attach it here, then you could now (with 11 posts) post a link to a file-sharing site.

    Administrative Note:

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below or the REPLY button instead of REPLY WITH QUOTE.

  27. #27
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Sorry I missed your message. Yes I have tried ISNUMBER(SEARCH) but it doesnt work as OfferinOC is a named range for an entire column of data. Earlier, the column would have only 1 value but now it has multiple values.
    Thanks.
    Last edited by anandis; 08-04-2020 at 03:06 AM. Reason: deleting quote

  28. #28
    Forum Guru
    Join Date
    05-24-2011
    Location
    Kuwait
    MS-Off Ver
    Office 365
    Posts
    2,199

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Quote Originally Posted by anandis View Post
    ...OfferinOC is a named range for an entire column of data...
    Your INDEX function referring to a table named OfferDetails & the named range OfferinOC refers to entire column?. Replace your named range to actual column in the table. ie;

    ISNUMBER(SEARCH(rngOC,OfferDetails[Column Name]))

  29. #29
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Phew. Managed to upload and attach. Please see the formula in Column D in Sheet Order-Conf (Rows 14,15,16)

    Thank you !
    Attached Files Attached Files

  30. #30
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    6,749

    Re: Is Countif the correct function to match a substring in a range to a selected value

    How about in D14 then copy down and accross:

    Please Login or Register  to view this content.

  31. #31
    Forum Guru
    Join Date
    05-24-2011
    Location
    Kuwait
    MS-Off Ver
    Office 365
    Posts
    2,199

    Re: Is Countif the correct function to match a substring in a range to a selected value

    In B14, copy down & across (Array Formula)

    =IFERROR(INDEX(OfferDetails[#Data],SMALL(IF(ISNUMBER(SEARCH(rngOC,OfferDetails[OC '#])),ROW(OfferDetails[#Data])-ROW(OfferDetails[#Headers])), ROW(1:1)), MATCH(B$13, OfferDetails[#Headers], 0)),"")

  32. #32
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    This didnt work and the cell returns a blank. I also didn't understand 15,6 function num?

  33. #33
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Haseeb A , Thank you ! This works perfectly.
    I spent hours trying to use ISNUMBER(SEARCH) but each time failed to get it to work.
    Would you mind telling me why search worked and countif failed too?

    Thanks again !
    (I'll mark the thread as solved)

  34. #34
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    6,749

    Re: Is Countif the correct function to match a substring in a range to a selected value

    See atahment where I apply the formula.
    Attached Files Attached Files

  35. #35
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    6,749

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Quote Originally Posted by anandis View Post
    ...why search worked and countif failed too?
    COUNTIF(RANGE,criteria) produces a single result, not a range of 1/0

  36. #36
    Registered User
    Join Date
    08-02-2020
    Location
    nerul,mahrashtra
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: Is Countif the correct function to match a substring in a range to a selected value

    Ok got it. I will study how AGGREGATE works. It's smaller and neater than the index/match formula i had ! Thanks !

+ 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] Find substring in range and categorise cells in range based on substring found
    By Stavrosis in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-15-2020, 11:50 AM
  2. [SOLVED] Countif/s searching 2 criteria and 2 range and only counting if both are correct
    By officialhoad in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-05-2018, 06:33 AM
  3. Countif function did not return correct values
    By ceishue in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-10-2016, 03:09 PM
  4. Countif function did not return correct values
    By ceishue in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-10-2016, 10:38 AM
  5. Frequency function to correct ranking instead of countif
    By Scottlarock in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 08-03-2013, 07:40 PM
  6. Search substring within range, report the substring found
    By Brooke1578 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-20-2012, 03:56 PM
  7. Looking for a correct COUNTIF function
    By Smit22 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-26-2012, 02:02 PM

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