+ Reply to Thread
Results 1 to 8 of 8

Macro for extracting text from one cell and entering it into cell beside

  1. #1
    Registered User
    Join Date
    05-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Macro for extracting text from one cell and entering it into cell beside

    Hi there

    In one column (Column A) I have a column of data which contains long descriptive text - i want to extract a specific piece of text from this descriptive text and enter it into the next Column (Column B).

    E.g. Cell A1 = "Hello Buddy, how are you?" - i want to extract the word Buddy and enter it into cell B1

    then A2 into B2, A3 into B3, etc, etc,...

    Is there a simple macro out there that can do this?

    I know a little bit about macros but not enough to do this.

    Appreciate anyone's help
    Regards
    John
    Last edited by jmurray; 06-06-2009 at 05:15 AM.

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Macro for extracting text from one cell and entering it into cell beside

    Welcome to the forum!

    Insert a Module and paste this in the Visual Basic Editor. Use it as commented. Notice that the 2nd parameter is the word number to pick and the 3rd parameter allows it to strip trailing characters.
    Please Login or Register  to view this content.
    A better solution would use regular expressions.

  3. #3
    Registered User
    Join Date
    05-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Macro for extracting text from one cell and entering it into cell beside

    Hi Kenneth

    Thanks for your reply. Actually I should have been more specific about what i want.

    I have a list of names on one sheet - i want to match these names to the long descriptions on another sheet - so i need the long descriptions to look through the list of names on the first sheet and bring back the relevant name in the cell next to it.

    I think the macro you kindly provided can only look for one name at a time? not sure?

    Appreciate any more hoel you can give on this one.

    Thanks
    John

  4. #4
    Registered User
    Join Date
    05-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Macro for extracting text from one cell and entering it into cell beside

    Hi again

    Thought I'd attach an example file to make the situation clearer - hope this helps.

    it shows the target list on the sheet "List" and these targets need to be populated into the yellow highlighted column on the second sheet ("Data").

    Thanks again
    John
    Attached Files Attached Files

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro for extracting text from one cell and entering it into cell beside

    Put this formula in Data!B2 and drag down
    =INDEX(List!$A2:$A$119,MATCH(FALSE,ISERROR(SEARCH(List!$A$2:$A$119,A2)),0),1)

    This needs to be confirmed with Ctrl-Shift-Enter (Cmd+Return for Mac)
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Registered User
    Join Date
    05-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Macro for extracting text from one cell and entering it into cell beside

    hi - this formula gives me #N/A values

    i tried holding Ctrl-Shift-Enter on this column B after dragging the formula but nothing changed, still #N/A values

    any ideas?

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro for extracting text from one cell and entering it into cell beside

    see the attached
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Smile Re: Macro for extracting text from one cell and entering it into cell beside

    Thank you! I had forgot to put the {} around the formula - thanks again!

+ 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