+ Reply to Thread
Results 1 to 13 of 13

Match any value in row array to column headings

  1. #1
    Registered User
    Join Date
    11-13-2010
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    7

    Match any value in row array to column headings

    Hi,

    I am struggling to find a formula that will approximately match all of the data in column b:d to the headings in e1:f1 and return "X" in the vertex. Attached is a simple example. I actually have 6 "forum" columns and more than 20 column headings to match (e.g. "abc").

    a1:a4 = name/contact
    b1:b4 = forum(1)
    c1:c4= forum (2)
    d1:d4 = forum (3)
    e1 = "abc"
    e2 = "def"

    The closest I got to the formula is for 1 x "forum" only.
    =if(sblank(a2,"",if(isna(match("*"&right(a2,5)&"*",e1,0),"",(match("*"(a2,5)&"*",e1,0))))

    I am using microsoft excel 2003

    Help!
    Attached Files Attached Files

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Match any value in row array to column headings

    sorry can't quite see what you are doing, perhaps its over simplified.
    because at first look you just need in e2 =if(countif($B$2:$d$2,$e$1,"x","")
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Match any value in row array to column headings

    Place the following array formula into E2, then confirm it by pressing CTRL-SHIFT-ENTER

    =IF(A2="","", IF(OR(ISNUMBER(SEARCH(E$1, $B2:$D2))), "x", ""))


    Copy that cell to the right. Then copy the pair of cells downward.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Match any value in row array to column headings

    I think you meant:
    =IF(ISBLANK(A2),"",IF(ISNA(MATCH("*"&RIGHT(A2,5)&"*",E1,0)),"",MATCH("*"&RIGHT(A2,5)&"*",E1,0)))

    Of which the real brain of the formula is:
    MATCH("*"&RIGHT(A2,5)&"*",E1,0)

    Your example doesn't make sense to me though, are you expecting to find the names in column A in the top row? Also, did you mean:
    Please Login or Register  to view this content.
    or should it have been:
    Please Login or Register  to view this content.
    If it's the first I think I need a bit more help with the logic...
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  5. #5
    Registered User
    Join Date
    11-13-2010
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Match any value in row array to column headings

    thanks for the quick reply. I tried:

    =IF(A2="","", IF(OR(ISNUMBER(SEARCH(E$1, $B2:$D2))), "x", ""))

    it worked for cell e2, however when I copy the formula across, it does not recognise a match with f1.
    In other words, the formula worked for "jane"'s data, not for "julie"'s data - i.e. F4. Help!

  6. #6
    Registered User
    Join Date
    11-13-2010
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Match any value in row array to column headings

    Oops - sorry. You are right, it's the second code:

    | X | |
    | | X |
    | X | X |

  7. #7
    Registered User
    Join Date
    11-13-2010
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Match any value in row array to column headings

    Quote Originally Posted by Cheeky Charlie View Post
    I think you meant:
    =IF(ISBLANK(A2),"",IF(ISNA(MATCH("*"&RIGHT(A2,5)&"*",E1,0)),"",MATCH("*"&RIGHT(A2,5)&"*",E1,0)))

    Of which the real brain of the formula is:
    MATCH("*"&RIGHT(A2,5)&"*",E1,0)

    Your example doesn't make sense to me though, are you expecting to find the names in column A in the top row? Also, did you mean:
    Please Login or Register  to view this content.
    or should it have been:
    Please Login or Register  to view this content.
    If it's the first I think I need a bit more help with the logic...
    Quote Originally Posted by JBeaucaire View Post
    Place the following array formula into E2, then confirm it by pressing CTRL-SHIFT-ENTER

    =IF(A2="","", IF(OR(ISNUMBER(SEARCH(E$1, $B2:$D2))), "x", ""))


    Copy that cell to the right. Then copy the pair of cells downward.
    Hi Jerry,

    Your formula was helpful. I've modified the formula to below - can you suggest how i can match "approximate" matches?

    Formula so far is:
    =if(b2="","",if(or(isnumber(search(e1,b2)),(isnumber(search(e1,c2))),"x",""))

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Match any value in row array to column headings

    Your formula "so far" undoes the point of the formula I gave you. You're expanding it back out for cell-by-cell tests when my original formula tested all 3 cells just fine. See:

    =IF(A2="","", IF(OR(ISNUMBER(SEARCH(E$1, $B2:$D2))), "x", ""))

    ...confirmed with CTRL-SHIFT-ENTER.

    This construct will also match substrings, so if E$1 has "drug" in it and one of the red cells has "Drugs" or "Drug Dealer", the match is confirmed. That's as "close" as I can get matching words.

  9. #9
    Registered User
    Join Date
    11-13-2010
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Match any value in row array to column headings

    Thanks for trying, your formula doesn't seem to work on excel 97.

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Match any value in row array to column headings

    there's nothing used in that formula that wont work in 97 it works just fine in my version
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Match any value in row array to column headings

    lol @ choice of example!

  12. #12
    Registered User
    Join Date
    11-13-2010
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Match any value in row array to column headings

    Hi,

    I've attached a modified spreadsheet to indicate what I am trying to achieve. This might be a clearer example.
    Attached Files Attached Files

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Match any value in row array to column headings

    Possibly this array formula in E2:

    =IF($A2="","", IF(OR(ISNUMBER(SEARCH($B$2:$D$2, E$1))), "x", ""))

    ...confirmed with CTRL-SHIFT-ENTER

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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