+ Reply to Thread
Results 1 to 13 of 13

How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKUP)?

Hybrid View

  1. #1
    Spammer
    Join Date
    06-09-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Microst Office 365 Plus
    Posts
    149

    How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKUP)?

    Hello, how can I check if a row in a table contains a given value? I was thinking to use COUNTIF + VLOOKUP but it doesn't work, because I can't use the VLOOKUP as a range in the COUNTIF formula.

    A B C D E F
    1 ID C1 C2 C3 C4 C5
    2 A 1 6 13 19 33
    3 B 2 5 16 22 29
    4 C 3 7 14 29 35

    I have the ID and I have to check if the ID row contains the given value, my idea was to use this formula:
    Formula: copy to clipboard
    =COUNTIF(VLOOKUP("B",A2:F4,{2,3,4,5,6},FALSE),22)

    Because the B row contains the value 22 I was expecting to get a 1, but excel doesn't accept the formula.
    How can I solve this problem?

  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,421

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    How about this?

    =LET(f,FILTER(B2:F4,A2:A4="B"),COUNT(FILTER(f,(f>=2)*(f<=6))))
    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
    Spammer
    Join Date
    06-09-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Microst Office 365 Plus
    Posts
    149

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Thanks, excel says that the function isn't valid
    Anyway I don't understand the filter part (f>=2)*(f<=6), how should this find if the row contains the value 22?

  4. #4
    Registered User
    Join Date
    12-07-2022
    Location
    Hoorn
    MS-Off Ver
    2210 excel
    Posts
    22

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    See attachement
    Attached Images Attached Images

  5. #5
    Spammer
    Join Date
    06-09-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Microst Office 365 Plus
    Posts
    149

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Thanks for the reply but actually I don't have to find the row containing the 22, I have the row ID and I have to check if the row contains the given number, i.e. does the row A contains the number 8? No. Does the row C contains the value 35? Yes. etc.

  6. #6
    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,421

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Quote Originally Posted by MoldyBread View Post
    Thanks for the reply but actually I don't have to find the row containing the 22, I have the row ID and I have to check if the row contains the given number, i.e. does the row A contains the number 8? No. Does the row C contains the value 35? Yes. etc.
    Isn't that what my solution does??? Maybe you failed to spot it ...

    Your attempt seemed to have the range 2 to 6. If you want 22, use this:

    =LET(f,FILTER(B2:F4,A2:A4="B"),COUNT(FILTER(f,f=22)))
    Last edited by AliGW; 12-08-2022 at 07:49 AM.

  7. #7
    Spammer
    Join Date
    06-09-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Microst Office 365 Plus
    Posts
    149

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Quote Originally Posted by AliGW View Post
    Isn't that what my solution does??? Maybe you failed to spot it ...

    Your attempt seemed to have the range 2 to 6. If you want 22, use this:

    =LET(f,FILTER(B2:F4,A2:A4="B"),COUNT(FILTER(f,f=22)))
    Sorry, it was a reply for TDus

  8. #8
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Put the row in I1 and the value in I2 and try
    Formula: copy to clipboard
    =ISNUMBER(MATCH(I2,INDEX(B2:F4,MATCH(I1,A2:A4),0),0))
    Attached Files Attached Files

  9. #9
    Spammer
    Join Date
    06-09-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Microst Office 365 Plus
    Posts
    149

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Quote Originally Posted by HansDouwe View Post
    Put the row in I1 and the value in I2 and try
    Formula: copy to clipboard
    =ISNUMBER(MATCH(I2,INDEX(B2:F4,MATCH(I1,A2:A4),0),0))
    Thanks, it worked, I had just to add an exact match for the MATCH function:
    Formula: copy to clipboard
    =ISNUMBER(MATCH(I2,INDEX(B2:F4,MATCH(I1,A2:A4,0),0),0))

  10. #10
    Registered User
    Join Date
    12-07-2022
    Location
    Hoorn
    MS-Off Ver
    2210 excel
    Posts
    22

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Here you go.
    (mind that H3 and H4 should be I2 and I3 instead)
    Attached Images Attached Images
    Last edited by TDus; 12-08-2022 at 08:58 AM.

  11. #11
    Spammer
    Join Date
    06-09-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Microst Office 365 Plus
    Posts
    149

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Quote Originally Posted by TDus View Post
    Here you go.
    (mind that H3 and H4 should be I2 and I3 instead)
    Thanks, this is working too

  12. #12
    Registered User
    Join Date
    11-24-2022
    Location
    France
    MS-Off Ver
    Office 365
    Posts
    11

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Nice one Tdus, tried something similar with hlookup, but i settled on a lazier solution.

    Attachment 808514

    Row 4 is a simple vlookup with the value in B4.
    J1 is a HLookup too.
    Tdus's answer is more elegant.

  13. #13
    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,421

    Re: How to match a row in a table and check if it contains a given value (COUNTIF + VLOOKU

    Please post your formulae in your posts instead of just screenshots. Nobody can copy and paste from a screenshot.

+ 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] Index,Match,CountIF Formula NOT working for removing duplicate rows frm Table- plz, Check?
    By sumans054 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-23-2019, 11:28 PM
  2. Replies: 4
    Last Post: 02-17-2019, 05:43 PM
  3. [SOLVED] CountIF and INDEX/MATCH or VLOOKUP or another?
    By er0_sennin in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-04-2018, 07:08 AM
  4. [SOLVED] Array, VLOOKUP - or- Match/index with a Countif.
    By JasonNeedsHelp in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-15-2015, 05:38 PM
  5. [SOLVED] COUNTIF integrated with a MATCH or VLOOKUP
    By jshaw82 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-22-2013, 05:48 PM
  6. Replies: 2
    Last Post: 03-16-2012, 12:03 PM
  7. COUNTIF/VLOOKUP/MATCH combination
    By gmcana in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-03-2008, 04:32 PM

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