Last active
September 29, 2015 10:08
-
-
Save mattcan/1584866 to your computer and use it in GitHub Desktop.
Flip "Lastname, Firstname" to "Firstname Lastname"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
' Note that Split always returns a 0-indexed array | |
''' | |
Option Explicit | |
Function flip_name(comma_sep_name As String) | |
Dim name_parts() As String | |
name_parts = Split(comma_sep_name, ",") | |
flip_name = Trim(name_parts(1)) & " " & Trim(name_parts(0)) | |
End Function | |
Sub fix_names(ByRef names As Excel.Range) | |
Dim name As Range | |
For Each name In names | |
name.Value = flip_name(name.Value) | |
Next name | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment