+ Reply to Thread
Results 1 to 5 of 5

VBA Code That Extracts Names/Characters Between Characters

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

    VBA Code That Extracts Names/Characters Between Characters

    HTML Code: 

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: VBA Code That Extracts Names/Characters Between Characters

    A few questions:
    example 1 shows the results as LASTNAME4, adam
    what denotes where the info to extract prior to the @ starts? is it any non alpha char? or just space or full stop?

    Example2
    How does Jennifer appear in the results? its not before an @ or after |,/ ?

    In the same way, in Example3 how does LASTNAME7 appear in the results?
    If someone has helped you then please add to their Reputation

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

    Re: VBA Code That Extracts Names/Characters Between Characters

    Example 1 - I need to extract the name prior to the "@". There are no non alpha characters.

    Example 2 - I need to extract LASTNAME3 JENNIFER from column A. Which would be the names after the last "-" in Column A

    Example 3 - I would need to extract the entire name before the "|"

  4. #4
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: VBA Code That Extracts Names/Characters Between Characters

    I think you need to define your extraction criteria exactly how you want it before any solution can be found, my issue with your original post was that the examples didnt match the request therefore there appears to be something thats not been defined.

    eg Example 2 doesnt contain any of the characters youve mentioned as being required
    loop through column A looking for @, |, or / and extract the names before @ and | or the names between /.
    yet your desired results show something I wouldnt have expected, Im assuming therefore that - needs to be added to the chars above, and then how do you define the "names" are they single words or 2 words split with a " ", what if theres a middle name? such as WHITFIELD, PETER JOHN etc

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

    Re: VBA Code That Extracts Names/Characters Between Characters

    Thanks pjwhitfield for your help. I know it's a bit confusing. If column A were all the same I think it would be easier. However, I have 3 different formats/criteria to evaluate in column A. Would this logic work?

    Function 1
    - Extract text after the last “-“
    Function 2
    - Extract text between the 2nd “/” and the “@”
    Function 3
    - Extract prior to 1st “|”

    If Find(“-“,A1) Then
    ActiveCell.Offset(0,1).Select = Function 1
    Else If
    Find(“@“,A1) Then
    ActiveCell.Offset(0,1).Select = Function 2
    Else
    Find(“|“,A1) Then
    ActiveCell.Offset(0,1).Select = Function 3
    End If
    Loop thru Column A

    I am really lost on this one.

    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. [SOLVED] VBA, remove all characters within a string, except numerical characters and full stops
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-25-2015, 09:24 PM
  2. [SOLVED] VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric
    By honger in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-11-2013, 01:05 AM
  3. [SOLVED] Delete characters and add * in front and last characters in ACCESS QUERY
    By LALTIZER in forum Access Tables & Databases
    Replies: 9
    Last Post: 02-01-2013, 02:06 PM
  4. Replies: 11
    Last Post: 01-23-2013, 02:04 PM
  5. [SOLVED] Extract left characters from string with exception of 2 right characters
    By sweetkel23 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-16-2012, 10:45 PM
  6. Replies: 2
    Last Post: 11-01-2011, 05:14 PM
  7. In Excel find characters when multiple characters exist w/i a cel
    By teacher-deburg in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-05-2005, 06:25 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