+ Reply to Thread
Results 1 to 11 of 11

VBA Needed to find number/text within cell string and copy out to new cell

  1. #1
    Registered User
    Join Date
    09-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    VBA Needed to find number/text within cell string and copy out to new cell

    Hi There,

    I am new to the forum, so sorry if below is not correct.....

    I have a spreadsheet with free text comment box dialogue in Column I.
    Within some of the comments are auto text strings "Resurrected from ######" (###### represents a 6 digit job number)
    There can be multiples of these strings in each comment, surrounded by other text.

    Is there some VBA that can pick out each of the 6 digit job numbers, and copy them into seperate cells to the right??

    May be asking for too much??

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

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    Can you upload a small sample workbook with the result that you want?

  3. #3
    Registered User
    Join Date
    09-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    Hi,

    Please see attachment below.
    I have highlighted the numbers i need out of the text in column I.
    There can be any amount of numbers per line, but usually no more than 3-4.

    Hope this helps. Let me know if i can provide anything else

    Thanks in advance for taking a look.


    delivery entries.xls

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

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    Try this
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    Hi Jindon,

    This works well. Thank very much
    Only problem is that it pulls all 6 digit numbers from column I.
    I only want the numbers that are preceded by "Resurected from".

    Thanks again for helping with this one.

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

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    OK.
    Change to
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    Jindon,

    Thanks so much.
    That works perfectly.

    Cheers

    AC

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    @ Campbell A

    Welcome to the forum.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  9. #9
    Registered User
    Join Date
    04-19-2013
    Location
    WsM, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    Hi there,
    I hope I am not hi-jacking anyone’s thread here, but as I am a newbie, I m not sure what the protocol is for wanting to ask a similar question to this one.
    Anyway, I have tried to figure out how this macro is working so I could apply it to my own scenario, but not having much luck.

    Instead of the 6 digits (is that what the "d" means in the macro - digits?) that A Campbell asked about, I would like to be able to retrieve data based on the format aaa-nnn (a is alpha and n being numeric in my simple world). The last ‘a’ of the 'aaa' format would need to be alpha numeric, as it could be either. The required data will always be in this format, but embedded amongst other text and numbers in the same cell. I can get the macro to pull out the last 3 digits after the “-“, but not quite what I need.
    Is this possible?

    Also, I wonder if it would be possible for someone to explain in layman’s terms what is happening at each stage of this macro? (ie .Pattern. I assumed ‘\d{6}’ is number of digits, but not sure what ‘\b’ is or the ‘\’ for that matter! I can understand some parts but not all, and my knowledge does not stretch far enough to know the alternative options, like selecting text etc.
    I record the occasional simple macros for work, and then search on-line for the odd clever trick or two to then enhance these to make them more efficient and sophisticated, but that's about it. Nothing too technical!
    Thanks in advance
    D

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

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    Google with the key words like

    VBA Regular Expressions Meta Character

    and you will find many sites explaining what you want to know.

  11. #11
    Registered User
    Join Date
    04-19-2013
    Location
    WsM, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA Needed to find number/text within cell string and copy out to new cell

    Jindon,
    Many thanks. Managed to work out how to get QQ1-111 by using pattern "([A-Z][A-Z]\w-\d{3})". Works a treat.
    Very much appreciated your direction on this.
    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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