+ Reply to Thread
Results 1 to 2 of 2

VBA Code to Extract Text Between Delimiter/Characters

  1. #1
    Registered User
    Join Date
    03-21-2010
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    90

    VBA Code to Extract Text Between Delimiter/Characters

    I have a column that contains names along with other characters in the cells. I would like help with a macro to extract the name from this column. I would like the code to go through each cell in column A and extract the name. Below is an example the spread sheet and what I want to see.

    Please Login or Register  to view this content.
    I would like the extract to be in the format of last name first comma then first name. But if I could just extract the name like above I'd be happy with that.

    Thanks!

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA Code to Extract Text Between Delimiter/Characters

    You don't need vba to do this. "Straight" excel can handle it. Look up the Find formula. You can start with using some helper cells and then if you really want to substitute the commands back until you define everything in terms of the column containing the name.

    However, you are going to have to define the "rules" - For example, if the line contains a "@", rule 1 applies: Look for the second slash and name starts there. Then look for @, name ends there. Substitute blank space for period.
    If the line contains "-", rule 2 applies: Look for the period, then look for the dash. Name starts there and goes to end of line
    If the line contains ",", rule 3 applies: Look for the comma - this is where the last name ends. Look for the pipe symbol. This is where the first name ends.

    Confirm that these are the rules. Then you can use find, left, right, mid and trim to parse out the pieces. I would advise against substituting the pieces back to make one master formula. It would most likely be so complicated that nobody would be able to understand it. Leave the helper columns in place.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. [SOLVED] Extract certain text dependant on number of characters in text
    By bjoanmark in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-28-2014, 02:57 AM
  2. Extract text between two characters in a string - varing text length
    By luv2birdie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-04-2014, 06:10 PM
  3. [SOLVED] Extract the first characters inside a cell up to a delimiter
    By pickslides in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2014, 08:50 PM
  4. [SOLVED] Extract 50 characters text to a new worksheet
    By skyflare in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2013, 01:44 AM
  5. Remove semi-colon delimiter from import-text code
    By ron2k_1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-17-2011, 11:20 AM
  6. Extract Text characters only from a cell
    By judasdac in forum Excel General
    Replies: 2
    Last Post: 05-06-2009, 12:22 PM
  7. Text to columns VBA code to change delimiter if the cell value is in array
    By dopple in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-26-2008, 09:25 AM

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