+ Reply to Thread
Results 1 to 19 of 19

Lookup text in shorter text

  1. #1
    Registered User
    Join Date
    04-09-2019
    Location
    Breda, Netherlands
    MS-Off Ver
    10
    Posts
    9

    Lookup text in shorter text

    Hi all,

    I have an question regarding the look of text in a table. I have periodic texts I want to look up and return a specific value.

    I want to look up the following texts:
    "Test/ Red 01-2019"
    "Test/ Red 02-2019"
    "Test/ Blue 01-2019"
    "Test/ Blue 02-2019"

    In a table that contains 2 columns:
    Text --- Value
    Test/ Red --- 5
    Test/ Yellow --- 7
    Test/ Blue --- 9
    Test/ Purple --- 11

    So "Test/ Red 01-2019" should give me the value 5. Does anyone know if this is possible? I know it is possible to look up "Test/ Red" in "Test/ Red 01-2019", but I want it the other way around.

    Is this possible?

    Thanks

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: Lookup text in shorter text

    Instead of using "Test/ Red 01-2019" as your lookup value, you could use LEFT("Test/ Red 01-2019",9) instead.

    Hope this helps.

    Pete

  3. #3
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Lookup text in shorter text

    Will this work with all instances, Pete?

    How about this?

    =LEFT(lookup_cell,FIND("0",lookup_cell)-2))
    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.

  4. #4
    Registered User
    Join Date
    04-09-2019
    Location
    Breda, Netherlands
    MS-Off Ver
    10
    Posts
    9

    Re: Lookup text in shorter text

    Hi Pete,

    You are correct yes. But however I was using this as a test and it can be 100 different titles instead of both 'test' and 'red'.

    I need something that like does a search from the first character until it finds a match, so in this case until the letter D of red. Without having to sum up the amount of characters cause this can be different every time.

    Thanks!

  5. #5
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Lookup text in shorter text

    Did you try my suggestion, which does just that???

  6. #6
    Registered User
    Join Date
    04-09-2019
    Location
    Breda, Netherlands
    MS-Off Ver
    10
    Posts
    9

    Re: Lookup text in shorter text

    Hi Ali,

    I tried your suggestion ofcourse, but then it is showing me an error if I do: =LEFT(A3,FIND("0",A3,-2)) I get an error (A3 is my lookup cell "Test/ Red 01-2019).
    If I do that it says #VALUE!. Besides that there is also the possibility that the text will say "Test/ Red 12-2019". In that case the 0 will be of no use I guess?

    Thanks for your time so far.
    Devon

  7. #7
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Lookup text in shorter text

    Instead of us having to guess, will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.

  8. #8
    Registered User
    Join Date
    04-09-2019
    Location
    Breda, Netherlands
    MS-Off Ver
    10
    Posts
    9

    Re: Lookup text in shorter text

    Here is the attachment with what the result should be. Yellow is where the formula is. The right table is where it should find the data and the left is the input.
    Attached Files Attached Files

  9. #9
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Lookup text in shorter text

    You missed some parenthesis. It should have been this:

    =LEFT(A2,FIND("0",A2)-2)

    However, try this instead:

    =LEFT(A2,FIND("-",A2)-4)

  10. #10
    Registered User
    Join Date
    04-09-2019
    Location
    Breda, Netherlands
    MS-Off Ver
    10
    Posts
    9

    Re: Lookup text in shorter text

    Ah yes that is it!!!!!!!!!!!!!!!!

    Thank you very much Ali!

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: Lookup text in shorter text

    Change the formula in B2 to this:

    =LEFT(A2,FIND(" ",A2,FIND("/ ",A2)+2)-1)

    Then in C2 you can have this:

    =VLOOKUP(B2,$F$2:$G$6,2,0)

    You may need to use semicolons ( ; ) instead of commas ( , ) in the formulae, depending on your regional settings. Then copy the formulae down.

    You could, of course, replace the B2 in the second formula with the first formula to have this:

    =VLOOKUP(LEFT(A2,FIND(" ",A2,FIND("/ ",A2)+2)-1),$F$2:$G$6,2,0)

    then you wouldn't need column B.

    Hope this helps.

    Pete

  12. #12
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Lookup text in shorter text

    Quote Originally Posted by Devon van Dam View Post
    Ah yes that is it!!!!!!!!!!!!!!!!

    Thank you very much Ali!
    You're welcome.

  13. #13
    Registered User
    Join Date
    04-09-2019
    Location
    Breda, Netherlands
    MS-Off Ver
    10
    Posts
    9

    Re: Lookup text in shorter text

    Hi Pete,

    Thank you I see this also brings the result. On other question though. Imagine I would have:
    Test/ Dummie Drop 2017
    Test/ Dummie Drop 2018
    Test/ Dummie Drop 2019

    What would I have to adjust in the =LEFT(A2,FIND(" ",A2,FIND("/ ",A2)+2)-1) to get the word "Test/ Dummie Drop".
    Cause when I adjust the +2 to +1 it only gives me "Test/" and when I adjust it to +3 it still shows "Test/ Dummie", same as with +2.

    See file blue cells.

    Thanks in advance.
    Attached Files Attached Files

  14. #14
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Lookup text in shorter text

    Devon - this is really frustrating. You keep introducing fresh problems by drip-feeding information about the data. In order to get a swift resolution, you need to tell us ALL possible data layouts.

  15. #15
    Registered User
    Join Date
    04-09-2019
    Location
    Breda, Netherlands
    MS-Off Ver
    10
    Posts
    9

    Re: Lookup text in shorter text

    I had no idea what was possible. I just want to know how to read this latest formula from Pete then I am done.

  16. #16
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Lookup text in shorter text

    No, you are not. Just by understanding the formula you are not going to solve the new problem. So, if you are unwilling to follow my advice, then I will leave you to others with more time than I have today. Good luck!

  17. #17
    Registered User
    Join Date
    04-09-2019
    Location
    Breda, Netherlands
    MS-Off Ver
    10
    Posts
    9

    Re: Lookup text in shorter text

    Sorry Ali, didn't want to make anyone upset. I will continue with what I have and leave the forum alone.
    Thanks for your time.

    Devon

  18. #18
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Lookup text in shorter text

    Here's one more guess in the absence of the full data required:

    =LEFT(A2,MIN(IF(ISNUMBER(FIND({1,2,3,4,5,6,7,8,9,0},A2)),FIND({1,2,3,4,5,6,7,8,9,0},A2)))-2)

    Excel 2016 (Windows) 32 bit
    A
    B
    1
    Text Formula 1
    2
    Test/ Dummie Drop 2017 Test/ Dummie Drop
    3
    Test/ Dummie Drop 2018 Test/ Dummie Drop
    4
    Test/ Dummie Drop 2019 Test/ Dummie Drop
    5
    Test/ Red 04-2019 Test/ Red
    6
    Test/ Red 05-2019 Test/ Red
    7
    Test/ Red 06-2019 Test/ Red
    8
    Test/ Red 07-2019 Test/ Red
    9
    Test/ Red 08-2019 Test/ Red
    10
    Test/ Red 09-2019 Test/ Red
    11
    Test/ Red 10-2019 Test/ Red
    12
    Test/ Red 11-2019 Test/ Red
    13
    Test/ Red 12-2019 Test/ Red
    14
    Dummie/ Blue 01-2019 Dummie/ Blue
    15
    Dummie/ Blue 02-2019 Dummie/ Blue
    16
    Dummie/ Blue 03-2019 Dummie/ Blue
    17
    Dummie/ Blue 04-2019 Dummie/ Blue
    18
    Dummie/ Blue 05-2019 Dummie/ Blue
    19
    Dummie/ Blue 06-2019 Dummie/ Blue
    20
    Dummie/ Blue 07-2019 Dummie/ Blue
    21
    Dummie/ Blue 08-2019 Dummie/ Blue
    22
    Dummie/ Blue 09-2019 Dummie/ Blue
    23
    Dummie/ Blue 10-2019 Dummie/ Blue
    24
    Dummie/ Blue 11-2019 Dummie/ Blue
    25
    Dummie/ Blue 12-2019 Dummie/ Blue
    Sheet: Sheet1
    Last edited by AliGW; 04-09-2019 at 08:24 AM.

  19. #19
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: Lookup text in shorter text

    In those particular cases in Post #13, you could use this approach:

    =LEFT(A1,LEN(A1)-5)

    Hope this helps.

    Pete

+ 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] 2 cell text lookup in text string to return data from separate column
    By Zivhodiva in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-08-2019, 03:03 PM
  2. Replies: 4
    Last Post: 03-15-2017, 03:36 PM
  3. [SOLVED] Lookup text in an array and match it with various specified text fragments
    By PaulAllen in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-31-2017, 10:25 PM
  4. Lookup & replace specific text in a text string
    By Haha88 in forum Excel General
    Replies: 1
    Last Post: 07-13-2015, 06:06 PM
  5. Lookup text from one sheet into another and sum the similar text values
    By irfanparbatani in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-18-2015, 07:39 PM
  6. Replies: 5
    Last Post: 11-05-2014, 01:49 AM
  7. [SOLVED] Split Long Text Cell into Two Shorter Cells Without Splitting Word
    By Naomi T in forum Excel General
    Replies: 1
    Last Post: 07-07-2005, 01:49 AM

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