+ Reply to Thread
Results 1 to 10 of 10

Need to find a particular sequence in a sentence

  1. #1
    Registered User
    Join Date
    11-18-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    20

    Need to find a particular sequence in a sentence

    Hello All,

    The objective is to look for a particular sequence in a sentence of every cell and if the sequence matches, then to pull that value.

    For Eg.

    I want to look for XXXX-YYYY, where and Y are all digits, may be same or different like 2341-3241. So whenever such sequence is found in a sentence, it must be able to pull out that sequence and paste it in another column.

    if the sentence is as below:

    Heater sequence 4543-2343 is to be rectified, then 4543-2343 is to be extracted out and copied into another cell, in same row.

    Please help on this.

    THank You,
    Bharat

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Need to find a particular sequence in a sentence

    OK so how will you know what the sequence is?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Need to find a particular sequence in a sentence

    is X all digits as well?
    how do you want to pull the data?

    you want to use a UDF or macro?

    either way this can help
    http://stackoverflow.com/questions/2...cell-and-loops
    Last edited by humdingaling; 06-11-2015 at 11:49 PM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Registered User
    Join Date
    11-18-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    20

    Re: Need to find a particular sequence in a sentence

    Hi Dibbins,

    Thanks for responding.

    Sequence can be anything of numbers, like if there are '4 digits' and then - and then '4-digits' like 4312-1414, then that should be identified as sequence. So basically I can say it will be a 9 letter word, in which mid letter is "-" and rest all are digits. So if there is such a 9 letter word in a sentence, it needs to be identified and picked from the sentence

  5. #5
    Registered User
    Join Date
    11-18-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    20

    Re: Need to find a particular sequence in a sentence

    Quote Originally Posted by humdingaling View Post
    is X all digits as well?
    how do you want to pull the data?

    you want to use a UDF or macro?
    Yeah, X will all be digits. I will need a macro. I don't mind using a UDF
    I have many such sequences, I thought I can develop if I can get the initial one. My another sequence would be word with 8 characters, first character as "alphabet", rest 7 are digits. I hope I can figure out my other requirement needs if I can get for 1 sequence.

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Need to find a particular sequence in a sentence

    i did a mock up for you
    see attached file with UDF


    pattern code for 1 lowercase alpha and 7 digits is

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by humdingaling; 06-12-2015 at 01:37 AM.

  7. #7
    Registered User
    Join Date
    11-18-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    20

    Re: Need to find a particular sequence in a sentence

    Oh god..you have really given an awesome simple solution. Thanks a lot

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Need to find a particular sequence in a sentence

    the pattern is sometimes fiddly to figure out but since the syntax is all in place its only a matter of searching for the right pattern

    the link in post #3 is a good start but if that is not enough just google "Regular expression VBA Excel"

  9. #9
    Registered User
    Join Date
    11-18-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    20

    Re: Need to find a particular sequence in a sentence

    Quote Originally Posted by humdingaling View Post
    the pattern is sometimes fiddly to figure out but since the syntax is all in place its only a matter of searching for the right pattern

    the link in post #3 is a good start but if that is not enough just google "Regular expression VBA Excel"
    Your code has solved my requirement. Really a lot thankful. Shall follow the above link too.

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Need to find a particular sequence in a sentence

    not a problem

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

+ 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. Find word in sentence
    By mastaliyev in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-11-2015, 06:05 AM
  2. to find a word in a sentence in acell
    By erickmcburger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2014, 08:37 AM
  3. Find word in sentence
    By WCE_123 in forum Excel General
    Replies: 2
    Last Post: 09-21-2011, 06:59 AM
  4. How to find and replace a word in a sentence with VBA
    By Gunilla in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-20-2010, 09:52 PM
  5. Find if 4 criteria in a sentence
    By eitancoh in forum Excel General
    Replies: 4
    Last Post: 08-14-2008, 05:04 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