+ Reply to Thread
Results 1 to 18 of 18

Search cell for words in table and then return table header

  1. #1
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Search cell for words in table and then return table header

    Hi,

    I have a list of transactions. I need to label them with a type by checking them against a table and then returning the column header.

    I have something that is working (which somebody on here helped me with already)

    ..however, my current solution searches the table for words on the transaction list. If the exact match isn't on the list then it doesn't work. For example, if I have Tesco on the data table but my list says "Tesco 1234", i don't get a match.

    I think I need to be searching the list for words from the table instead (so searching the list for "Tesco" instead of searching the table for "Tesco 1234") ...or something like that. But I can't figure it out.

    See attached example.


    Thanks in advance for any help!
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Search cell for words in table and then return table header

    Hi Leo,

    See if this will do you for a while. I reformatted your lookup list and then did an Index match search. I also created two Dynamic Named Ranges to make it work if the lists grow.

    NOTE - this only works if you sort by the first column.

    Charge to Category Index Match Alpha List.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    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,152

    Re: Search cell for words in table and then return table header

    with list in column as per Marvin's post:

    =INDEX(PAYEES!$B$1:$B$27,SUMPRODUCT(--(ISNUMBER(SEARCH(PAYEES!$A$1:$A$27,C1)))*ROW($A$1:$A$27)))

    List does not need to be sorted.

  4. #4
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search cell for words in table and then return table header

    I'm ideally looking for a formula that works in place without changing the Payees page.

    I need the Payees page to remain as it is.
    Last edited by leovfx; 04-30-2017 at 05:41 PM.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Search cell for words in table and then return table header

    Hi leo,

    I keep running into questions that are just too hard (like your problem). Using VBA or "Fuzzy Logic" your problem is still hard. I've done a similar problem for myself using a long list of credit card transactions. I would then create an Advanced filter with words, but put "*" in front and behind each word. This then does a wildcard search and would find what you want in your post. Instead you want a formula that looks into one text string for another. In your Tesco example, the match isn't exact, so wildcard search is the best. But then you want two ranges to search between each other. Now the problem just gets too hard for a simple Excel formula.

    Read up on a problem like yours at:
    http://www.excel-university.com/perf...okup-in-excel/
    Maybe they've solved it.

    Edit: It looks like the Fuzzy Add-In would do your problem, but then I don't think it works on a Mac.
    Last edited by MarvinP; 05-01-2017 at 01:48 AM.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Search cell for words in table and then return table header

    Another way.

    Array enter this formula in H1 and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The array constant {1,1,1} can be determined by additional calculation in case number of rows is not constant. Let me know.
    Last edited by FlameRetired; 04-30-2017 at 10:32 PM.
    Dave

  7. #7
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search cell for words in table and then return table header

    Dave. That's amazing. I wish I fully understood it.

    The Payees list will change number of rows over time. On my actual workbook it's already at 200.

    I think I'll need some help with that additional calculation you mentioned.

    What's the best way to count longest column in the array and return {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,..... to the length of the count?

    Thanks for everything so far.
    Last edited by leovfx; 05-01-2017 at 03:43 AM.

  8. #8
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search cell for words in table and then return table header

    Is this bad practice?:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,366

    Re: Search cell for words in table and then return table header

    Hope this works
    Attached Files Attached Files

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Search cell for words in table and then return table header

    Quote Originally Posted by leovfx View Post
    Is this bad practice?:

    Please Login or Register  to view this content.
    No. When the number of rows is small and unchanging it's more efficient. It's just gets awkward when the number of rows in the source range become large ... like 200 ... or change frequently.

    Swap {1,1,1} for TRANSPOSE(ROW(INDIRECT("1:"&ROWS(PAYEES!$A$2:$K$100))))^0 That will return how ever many 1s = rows in PAYEES!$A$2:$K$100.

    Then consider naming the range PAYEES!$A$2:$K$100 and then replacing the range reference(s) with that name. That way you just have to edit the range in Name Manager once rather than multiple times in the formula.

    PS. Another alternative would be COLUMN(INDEX($1:$1,1):INDEX($1:$1,ROWS(PAYEES!$A$2:$K$100)))^0. It's longer but in case the volatile INDIRECT starts to slow the workbook down this could be a fall back.

  11. #11
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search cell for words in table and then return table header

    Great. Thanks so much for this.

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Search cell for words in table and then return table header

    You're welcome. Thanks for the feedback.

  13. #13
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search cell for words in table and then return table header

    Hi,

    One last thing to make this perfect...

    Currently the search appears to be case sensitive. Is there a simple way to change it so that it isn't?

    Can I just change FIND to SEARCH or is there a special reason that you used FIND that I'm overlooking?
    Last edited by leovfx; 05-01-2017 at 04:44 PM.

  14. #14
    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,152

    Re: Search cell for words in table and then return table header

    Replace FIND with SEARCH

  15. #15
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Search cell for words in table and then return table header

    Thanks for the back-up John.

  16. #16
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search cell for words in table and then return table header

    Nice one guys!!

  17. #17
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search cell for words in table and then return table header

    Nice one guys!

  18. #18
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Search cell for words in table and then return table header

    _______________

+ 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. Replies: 2
    Last Post: 03-30-2017, 08:54 PM
  2. [SOLVED] search table for unique values, return value and corresponding cell to another sheet
    By thara95 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-06-2017, 09:47 AM
  3. Replies: 3
    Last Post: 08-13-2015, 10:07 PM
  4. [SOLVED] Find specific value in table and return header row and header column value
    By nelwan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-30-2013, 01:35 AM
  5. [SOLVED] Return the column header for every value 'x' along each row in table
    By pcassidy in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-21-2013, 06:49 PM
  6. Vlookup return the header name of table (Table of 4 column x 55 rows)
    By sanpat in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-09-2013, 11:23 PM
  7. [SOLVED] Search for a number in a table and return data of a specific cell
    By Karaman in forum Excel General
    Replies: 4
    Last Post: 06-30-2006, 10: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