Consulting

Results 1 to 10 of 10

Thread: if and match formula

  1. #1
    VBAX Regular
    Joined
    Aug 2017
    Posts
    57
    Location

    Arrow if and match formula

    Why does this formula not work? Thanks.

    =IF(ISNUMBER(MATCH($j1,$A6:$G6,0)),$j1,IF(ISNUMBER(MATCH($j2,$A6:$G6,0)),$j2,IF(AND(ISNUMBER(MATCH($j1,$A6:$G6,0)),ISNUMBER(MATCH($j2,$A6:$G6,0))),"$j1,$j2","")))

  2. #2
    VBAX Regular
    Joined
    Aug 2017
    Posts
    57
    Location
    ok. if I order the formula this way, it works.

    =IF(AND(ISNUMBER(MATCH($j1,$A6:$G6,0)),ISNUMBER(MATCH($j2,$A6:$G6,0))),"$j1 ,$j2",IF(ISNUMBER(MATCH($j1,$A6:$G6,0)),$j1,IF(ISNUMBER(MATCH($j2,$A6:$G6,0 )),$j2,IF(AND(ISNUMBER(MATCH($j1,$A6:$G6,0)),"")

    but I still have a problem with this part
    "$j1,$j2"
    instead of showing the values in j1 and j2 , I get $j1,$j2 literally. what should i do to fix this problem?
    Last edited by Mati44; 07-18-2018 at 11:28 AM.

  3. #3
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,194
    Location
    What happens if you replace it with:
    $j1,$j2
    Instead of:
    "$j1,$j2"
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post (you may need to click 'Go Advanced')

    Excel 365, Version 2403, Build 17425.20146

  4. #4
    VBAX Regular
    Joined
    Aug 2017
    Posts
    57
    Location
    The formula doesn't work. I get: "you've entered too many arguments for this function" error.

  5. #5
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,194
    Location
    Should j1 be if true and j2 if false?
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post (you may need to click 'Go Advanced')

    Excel 365, Version 2403, Build 17425.20146

  6. #6
    VBAX Regular
    Joined
    Aug 2017
    Posts
    57
    Location
    if j1 and j2 are in the $A6:$G6 range, the values of j1 and j2, should be placed in the cell, eg, "1,2".
    if one of them in the range, then it should be that number in the cell.

  7. #7
    VBAX Regular
    Joined
    Aug 2017
    Posts
    57
    Location
    So basicaly, I seek two numbers (a,b) in a range (A6:G6), if they are both in the range, then it should be like "a,b". if one of them in the range, then it should "a", or "b" in the target cell.

  8. #8
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,194
    Location
    How about:
    =IF(AND(ISNUMBER(MATCH($J1,$A6:$G6,0)),ISNUMBER(MATCH($J2,$A6:$G6,0))),$J1&"," & $J2,IF(ISNUMBER(MATCH($J1,$A6:$G6,0)),$J1,IF(ISNUMBER(MATCH($J2,$A6:$G6,0 )),$J2,"Not found")))
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post (you may need to click 'Go Advanced')

    Excel 365, Version 2403, Build 17425.20146

  9. #9
    VBAX Regular
    Joined
    Aug 2017
    Posts
    57
    Location
    Thank you very much. How couldn't I think of this? I forgot about &.

  10. #10
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,194
    Location
    No problem, another way maybe:
    =IF(COUNTIF(A6:G6,J1)+COUNTIF(A6:G6,J2)>1,J1&","&J2,IF(COUNTIF(A6:G6,J1)>0,J1,IF(COUNTIF(A6:G6,J2)>0,J2,"Not found")))
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post (you may need to click 'Go Advanced')

    Excel 365, Version 2403, Build 17425.20146

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •