Consulting

Results 1 to 7 of 7

Thread: Name Splitter Help

  1. #1
    VBAX Newbie
    Joined
    Feb 2014
    Posts
    4
    Location

    Name Splitter Help

    I am fairly new to VBA, and I know that there is a text to column button in Excel Data, but when I enter new names, it does not work for them. I need this program to run every time I type in a name. Also, I need it to split each name into its letter components. For example: "John James Doe" needs to be separated into "J O H N" in one column, "J A M E S" in a second column, and "D O E" into a third with each letter in a separate cell. If there is someone who could help me with this it would be greatly appreciated. Thanks!

  2. #2
    i am not sure this is what you want, but you may be able to figure out

    Private Sub Worksheet_Change(ByVal Target As Range)
    If InStr(Trim(Target), " ") Then
        Application.EnableEvents = False
        nm = Split(Target)
        For i = 0 To UBound(nm)
            For j = 1 To Len(nm(i))
                Target.Offset(j - 1, i).Value = Mid(nm(i), j, 1)
            Next
        Next
        Application.EnableEvents = True
    End If
    End Sub
    this program to run every time I type in a name
    the above will run every time something is typed in, that contains a space, can not tell if it a name or not

  3. #3
    VBAX Newbie
    Joined
    Feb 2014
    Posts
    4
    Location
    I'm not sure I know how to use this macro. How am I supposed to run it?

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Place it in the sheet module for the sheet you want it to run on
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Newbie
    Joined
    Feb 2014
    Posts
    4
    Location
    I have it in the module, but when I try to run it I get nothing. Does it automatically run?

  6. #6
    Does it automatically run?
    yes, as long as it is in the correct module, must be the codepame for the sheet you want it to work with

  7. #7
    VBAX Newbie
    Joined
    Feb 2014
    Posts
    4
    Location
    Quote Originally Posted by westconn1 View Post
    yes, as long as it is in the correct module, must be the codepame for the sheet you want it to work with
    Thanks man, just got it working. Does exactly what I want it to.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •