Automatically rearranging text in a cell
Here is a function that you can use... Add this code to a standard code
module (the same place that a recorded macro would be)
Public Function FormatName(ByVal InputName As String) As String
FormatName = Right(InputName, Len(InputName) - _
InStrRev(Trim(InputName), " ")) & _
", " & Trim(Left(InputName, InStrRev(InputName, " ")))
End Function
You can use this the same way you would use any excel function, so if your
name is in Cell A1 in Cell B1 put
=FormatName(A1)
--
HTH...
Jim Thomlinson
"faerie_bel" wrote:
I have a spreadsheet listing names of people. I copy/paste the full name of
the person from another program into my spreadsheet, but my problem is that I
then need to display it with the Surname first. eg: if the name is "Joe
Smith", I want it to display as "Smith, Joe". Is there a Macro or something
that can automate this process for me? I'm new to Macros and couldn't get one
to work properly.
Thanks in advance!
|