+ Reply to Thread
Results 1 to 18 of 18

How to extract multiple instances of a keyword from a cell?

  1. #1
    Registered User
    Join Date
    03-03-2006
    Posts
    27

    How to extract multiple instances of a keyword from a cell?

    I wanna extract anyt text in a call that starts with LQ1 to a length of 10 characters to an empty cell, coma delimited. Is this possible?

  2. #2
    Forum Contributor
    Join Date
    02-28-2006
    Posts
    690
    using search you can find the location (in characters in from the start) of the text LQ1

    eg text is applesLQ1pearsplumsoranges

    the search returns 7

    LEN(cellref) returns 26

    MID(cellref,7,10) returns LQ1pearspl

  3. #3
    Registered User
    Join Date
    03-03-2006
    Posts
    27
    Thanks rob, but this does not handle multiple instances of LQ1 in the text. So if I have text like applesLQ1pearsplumsoranges peacheslq1iloveanddig'em, I would like to get'em as LQ1pearspl, lq1ilovean

  4. #4
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Not exactly sure what you want, but does this help, with your text in A1, put this in B1

    =IF(LEFT(A1,3)="LQ1",LEFT(A1,3),"")

    and this in C1

    =IF(IF(LEFT(A1,3)="LQ1",LEFT(A1,3),"")="LQ1",MID(A1,4,7),"")
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  5. #5
    Forum Contributor
    Join Date
    02-28-2006
    Posts
    690
    applesLQ1pearsplumsorangespeacheslq1iloveanddig'em

    search to find the first example of LQ1 (at character 7)


    in a temporary helper cell insert the formula

    =mid(textcellref,search(textcellref,"LQ1")+10,200)

    in here you will see umsorangespeacheslq1iloveanddig'em

    now do the search on this cell

    you can have as many tries as you like, you will get error messages where only one instance of LQ1, but you can trap these out using ISERROR

  6. #6
    Registered User
    Join Date
    03-03-2006
    Posts
    27
    A better example

    FRN EMTN 08/2007 CAD10000'B1339' 4.472 08/20/2007
    Issuer: Abbey National Treasury Services plc (LSE:57AY) (IQT32033759)
    08/20/2007

    FLTG RATE NTS 8/2007 JPY100000000 4.333 08/21/2007
    Issuer: Abbey National Treasury Services plc (LSE:57AY) (IQT31942187)
    08/21/2007

    FR GTD EMTN 22/08/2007 GBP100000 'B1340' 5.758 08/22/2007
    Issuer: Abbey National Treasury Services plc (LSE:57AY) (IQT32037171)
    08/22/2007

    I need to put in the formula in a single cell to get the coma delimited list of the IQT id's

  7. #7
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Try this,

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-03-2006
    Posts
    27
    Nope. Only gave me the first instance. - IQT32033759

  9. #9
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    I'm assumming that your sample is not in one cell here?? If it isn't, then auto-fill the formula down the column. Here's a link on auto-fill

    http://mistupid.com/viewlets/excel/xlautofill.htm

  10. #10
    Registered User
    Join Date
    03-03-2006
    Posts
    27
    As I mentioned in my original quote, it is in a single cell. Otherwise it would've been quite easy using find and mid.

  11. #11
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Does this help?
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    03-03-2006
    Posts
    27
    Thanks, it does. But the problem is the number of instance of IQT is not fixed and I have like 1000 rows of this data. The reason I'm pressing for a single formula is that I had seen it on the web and now I can't find it.

  13. #13
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    What would be the max number of IQT's per cell?

  14. #14
    Registered User
    Join Date
    03-03-2006
    Posts
    27
    That would be 5.

  15. #15
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Try this, formula in one cell, you need to hide the helper columns
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    03-03-2006
    Posts
    27
    It works!!. I'll use this till the time I get that single cell formula and post it here as well. Thanks a ton for the help.

  17. #17
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Glad to help - thanks for the feedback

  18. #18
    Forum Contributor
    Join Date
    02-28-2006
    Posts
    690

    A Macro Approach

    this will find any number of identical blocks in any number of cells - it is very low level coding!!!
    Attached Files Attached Files

+ 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