ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically rearranging text in a cell (https://www.excelbanter.com/excel-programming/359089-re-automatically-rearranging-text-cell.html)

faerie_bel

Automatically rearranging text in a cell
 
Thanks Jim - this worked beautifully! Saves me a bit of time. =)

"Jim Thomlinson" wrote:

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!



All times are GMT +1. The time now is 08:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com