+ Reply to Thread
Results 1 to 13 of 13

search for multiple text strings (this or that) simultaneously in a single cell

  1. #1
    Forum Contributor
    Join Date
    09-23-2015
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    187

    search for multiple text strings (this or that) simultaneously in a single cell

    Hello,

    This is quite complicated to explain so bare with me. I am dealing with the following strings in a column, I have thousands of rows so can't do this by hand

    L Z9
    LAQ18
    BAZ8
    XARU8
    CLQ8
    G U8
    HCN8
    IRM9
    MESU8
    MFSU8
    NGQ18
    etc...


    These unique codes follow a pretty random construction for the root (first few letters) but what is consistent with all of them is that the last 2 letters and sometimes 3 letters are the date, I'll explain further with the following.


    The last 2 or 3 letters always follow this legend where it is indicating a month and date

    F = Jan, G = Feb, H = Mar, J = Apr, K = May, M = Jun, N = Jul, Q = Aug, U = Sep, V = Oct, X = Nov, Z = Dec
    &
    8 = 2018, 9 = 2019, etc however some cases they actually put 2 numbers like 18 = 2018, 19 = 2019

    Example:MES being the root, would always be MES but can show up as MESU8 = MES Sept 2018 , MESQ8 = MES Aug 2018
    Or G U8 can be G K8 = G May 2018, G V9 = Oct 2019

    I am trying to get Excel to dynamically return me the position in the String where the custom code for the date starts, so I can Parce out just the Root. Keep in mind sometimes the last 2 letters are the date code, and sometimes its the last 3 letters. Can I get a formula that automatically knows?

    If you have any ideas I would greatly appreciate it, I know this was complicated and all but I hope I was clear in my objective
    Last edited by lougs7; 08-15-2018 at 03:51 PM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Maybe
    =IF(ISNUMBER(VALUE(RIGHT(A1,2))),RIGHT(A1,3),RIGHT(A1,2))

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Try this user defined function

    Please Login or Register  to view this content.
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a suitable cell, enter =GetRoot(A1)

    Remember to save the workbook as a macro enabled workbook .xlsm
    Martin

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Too Late

    Fluffs solution looks better.


    Please Login or Register  to view this content.
    Last edited by mehmetcik; 08-15-2018 at 04:03 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  5. #5
    Forum Contributor
    Join Date
    09-23-2015
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    187

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Quote Originally Posted by Fluff13 View Post
    Maybe
    =IF(ISNUMBER(VALUE(RIGHT(A1,2))),RIGHT(A1,3),RIGHT(A1,2))
    You rock man, I spent 2 hours on this. This works

  6. #6
    Forum Contributor
    Join Date
    09-23-2015
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    187

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.
    This also works, thanks a lot for the help

  7. #7
    Forum Contributor
    Join Date
    09-23-2015
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    187

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Quote Originally Posted by mrice View Post
    Try this user defined function

    Please Login or Register  to view this content.
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a suitable cell, enter =GetRoot(A1)

    Remember to save the workbook as a macro enabled workbook .xlsm
    THank you very much! I will use one the the ways suggested, this also works

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Glad we could help & thanks for the feedback

  9. #9
    Forum Contributor
    Join Date
    09-23-2015
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    187

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Quote Originally Posted by mehmetcik View Post
    Too Late

    Fluffs solution looks better.


    Please Login or Register  to view this content.
    Hey Sorry to bug you again, but say I want to isolate the Root rather than the date code, how can I adapt this formula?

  10. #10
    Forum Contributor
    Join Date
    09-23-2015
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    187

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Quote Originally Posted by Fluff13 View Post
    Glad we could help & thanks for the feedback
    Hey Fluff, say I want to isolate the Root rather than the date code, so the BA in BAZ8 or the MES in MESU8 or the G in G U8, etc how I adapt this formula?? The Root is always before the date code but can be 2 letters long, 3 letters long, 1 letter long and a space, it always changes so can't use a left formula

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    How about
    =IF(ISNUMBER(VALUE(RIGHT(A1,2))),LEFT(A1,LEN(A1)-3),LEFT(A1,LEN(A1)-2))

  12. #12
    Forum Contributor
    Join Date
    09-23-2015
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    187

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    Quote Originally Posted by Fluff13 View Post
    How about
    =IF(ISNUMBER(VALUE(RIGHT(A1,2))),LEFT(A1,LEN(A1)-3),LEFT(A1,LEN(A1)-2))
    Your're a champ! thanks for the help

  13. #13
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: search for multiple text strings (this or that) simultaneously in a single cell

    You're welcome

+ 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. Search for multiple keywords within a single text cell
    By ndube50 in forum Excel General
    Replies: 22
    Last Post: 06-30-2020, 07:23 AM
  2. [SOLVED] Search for multiple cell contents in multiple text strings on two different worksheets
    By Sinistra in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-07-2017, 07:29 AM
  3. [SOLVED] Need to extract text from within multiple strings and arrange it in a single column
    By sampflederer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2013, 01:35 PM
  4. Truncate text strings using LEFT and FIND/SEARCH for multiple search terms
    By ngdoherty in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-17-2013, 07:51 PM
  5. Using multiple text strings in a single cell as Pivot labels
    By rsfx in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 11-14-2012, 08:09 AM
  6. Search for multiple strings simultaneously
    By denverdale in forum Excel General
    Replies: 5
    Last Post: 03-08-2011, 03:54 AM
  7. Replies: 2
    Last Post: 12-18-2009, 10:59 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