Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private tmpSurN 'temporary Surname storing
Private tmpForN 'temporary Forename storing
Private idx As Integer 'integer counter
'function to parse fullname into surname and forename
Function ParseName(sh As String, col As String, colPre As String, start As Integer)
'sh is the worksheet to be worked on
'col is the column in sh that the names are stored
'col pre is the column in sh that stores the forename
idx = start 'records might not start at 1st row
'loops through all non empty cells
With Worksheets(sh)
Do While idx < Worksheets(sh).Range(col & Rows.Count).End(xlUp).Offset(1, 0).row
'finds the first " " delimiter and separates name based on that
If (InStr(.Range(col & CStr(idx)).Value, " ") <> 0) Then
tmpForN = LTrim(RTrim(Left(.Range(col & CStr(idx)).Value, InStr(.Range(col & CStr(idx)).Value, " "))))
tmpSurN = LTrim(RTrim(Right(.Range(col & CStr(idx)).Value, Len(.Range(col & CStr(idx)).Value) - InStr(.Range(col & CStr(idx)).Value, " "))))
'then puts the forename into colPre
Worksheets(sh).Range(colPre & CStr(idx)).Value = tmpForN
Worksheets(sh).Range(col & CStr(idx)).Value = tmpSurN
End If
idx = idx + 1
Loop
End With
End Function