Skip to content

Instantly share code, notes, and snippets.

@mattcan
Last active September 29, 2015 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattcan/1584866 to your computer and use it in GitHub Desktop.
Save mattcan/1584866 to your computer and use it in GitHub Desktop.
Flip "Lastname, Firstname" to "Firstname Lastname"
'''
' 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