View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Switch names in cell

My typo. Application.split should just be Split.

This worked fine for me (xl2003)

Sub abc()
Dim cell As Range, sStr As String
For Each cell In Selection
v = Split(cell, ",")
sStr = Trim(Trim(v(UBound(v))) & " " & Trim(v(LBound(v))))
cell.Value = sStr
Next

End Sub


Note that split is not provided in xl97 and earlier.

--
Regards,
Tom Ogilvy

"tjtjjtjt" wrote in message
...
I got a run time error (438: Object doesn't support this property of

method)
on the line Application.Split.

I'll ultimately want to be able to identify the column of names within a
list of information and then switch the names.
The names are usually, but not always, in Column A, so the code will need

to
look for one of two words, "Name" or "Instructor," and then switch the

names
in every record.

--
tj


"Tom Ogilvy" wrote:

How robust does it need to be

Dim cell as Range, sStr as String
for each cell in Selection
v = Application.Split(cell,",")
sStr = Trim( trim(v(Ubound(v))) & " " & trim(v(Lbound(v))))
cell.Value = sStr
Next

--
Regards,
Tom Ogilvy

"tjtjjtjt" wrote in message
...
Does anyone have a routine that can take a list of names entered as
"Lastname, Firstname" and change those names to "Firstname Lastname"

within
the same cells?

Thanks,

--
tj