+ Reply to Thread
Results 1 to 12 of 12

extract multi-letter string bits from string depending on size and case

  1. #1
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    extract multi-letter string bits from string depending on size and case

    I have a bunch of cells on a sheet and need to find a specific one by a "key word" and then extract certain elements of it. The contents of the cell I'm looking for is similar to:

    "The symbols are: ABC, DEF, ASD; more symbols: SDSF, ASD; also: UOI, DGF". With my keyword being "The symbols are".

    If a cell containing this keyword is found, I'd like to extract only elements of it that have between 1 and 4 letters and are in all caps (the elements are stock symbols, fyi) and put it into an array held in VB memory that I can play with later. So, the exacted array would be: (ABC, DEF, ASD, SDSF, ASD, UOI, DGF).

    Is this possible to do? Note that the cell contents are rather sporadic and are not nicely separated by comma or a space and the keyword is not always in the very front either (sometimes there's more than one, but I'm starting with one), that's why I have the 1 to 4 letters and all caps criteria to find what I need.

    Thank you
    You either quit or become really good at it. There are no other choices.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: extract multi-letter string bits from string depending on size and case

    Made it as a UDF since you didn't tell us how you want the result
    Assuming the data in col.A

    use in cell like
    =IF(ISNUMBER(SEARCH("The symbols are",$A1)),IFERROR(GetSymbols($A1,COLUMN(A1),";",":","."),""),"")
    where bold part is the symbols that the data is separated. You can add more if you need to.
    COLUMN(A1) is used for 1 and this MUST not be changed when you enter the formula.

    Copy right + down and you will see the results.

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extract multi-letter string bits from string depending on size and case

    Wow, that is a handful! Thank you. I'm actually looking to do this completely in VBA within a larger code I'm writing. I did some searching and looks like I can use the InStr function to find my keyword:

    Please Login or Register  to view this content.

    Could you show me how to modify what you have for use just within VBA? I gave it a try and got error after error.

    Thanks so much.
    Last edited by luv2glyd; 02-17-2017 at 11:13 PM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: extract multi-letter string bits from string depending on size and case

    Result in Col.B to the right.
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extract multi-letter string bits from string depending on size and case

    Great! Are you able to make it so that the results are kept within a 1-dimensional array in VBA instead of being output to spread sheet?

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: extract multi-letter string bits from string depending on size and case

    Do you understand what you are saying?
    Please Login or Register  to view this content.
    x should be 1 d array.

  7. #7
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extract multi-letter string bits from string depending on size and case

    Quote Originally Posted by jindon View Post
    Do you understand what you are saying?
    Please Login or Register  to view this content.
    x should be 1 d array.
    Lol. Of course. Thank you so much for your help.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: extract multi-letter string bits from string depending on size and case

    Yeah, people would overlook the things easily sometimes.

    Thanks for the rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  9. #9
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extract multi-letter string bits from string depending on size and case

    You're welcome. I have not worked much with strings so takes a bit to comprehend.

  10. #10
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extract multi-letter string bits from string depending on size and case

    Sometimes there is more than one line with different keywords like "The symbols are" or "here are the symbols" or "symbol list". Each line will contain a different set of symbols. Is it possible to add these other symbols to the array x? Basically the logic would be if a line contains one of the keywords, then save the symbols on that line to x, move on to next line, if it contains one of the keywords, add these to x, and so on.
    Last edited by luv2glyd; 02-18-2017 at 03:05 PM.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: extract multi-letter string bits from string depending on size and case

    Something like
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: extract multi-letter string bits from string depending on size and case

    Great! Thank you.

+ 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. string manipulation, move letter back in the string
    By hammerjoe in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-22-2016, 12:49 PM
  2. [SOLVED] extract letter 3 4 5 from a string
    By makinmomb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-10-2014, 07:47 AM
  3. [SOLVED] VBA for searching string in a column and copy rows depending on string in adjacent cell
    By xprakash in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-20-2013, 05:58 AM
  4. Replies: 12
    Last Post: 03-20-2013, 05:46 PM
  5. Replies: 8
    Last Post: 09-27-2012, 10:46 PM
  6. [SOLVED] Help to extract a letter from a string
    By poli_ga in forum Excel General
    Replies: 5
    Last Post: 04-26-2012, 02:51 PM
  7. Pull (Extract) the First Letter of a String
    By DavidW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2006, 04:43 PM

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