Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split "Lastname, Firstname Middlename" 1

Status
Not open for further replies.

kstargold

Programmer
Jun 7, 2004
27
US
I have a listing of people that are in program at my university. The cells of the Excell sheet are formated "Lastname, Firstname Middlename". I'm working on doing a mail merge, so I need them in "Firstname Middlename Lastname" format.

I have learned a few things about spilt, but I don't know how to reorder the cell. This is what I have:

Code:
Private Sub CommandButton1_Click()
Dim Name As String
Dim lName As String
Dim fName As String
Dim i As Integer
i = 2

While Cells(i, "a").Value >= "0"
    Name = Cells(i, "b").Value
   'lName = Split(Name, ",")
    i = i + 1
Wend
End Sub

I need some way of deleting "len(lName)+ 2" (+ 2 for ", ") spaces from the front of the cell, but I don't know how to do that.

Any ideas?

Thanks,
Kanan
 
Something like this ?
Private Sub CommandButton1_Click()
Dim i As Integer, a
i = 2
While Cells(i, "a").Value >= "0"
a = Split(Cells(i, "b").Value, ",")
Cells(1, "c") = Trim(a(1)) & " " & Trim(a(0))
i = i + 1
Wend
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top