Sub ReorderNameUMH()
Dim lnRw As Long, lnNS As Long, lnNE As Long, sName As String
Dim lnIDS As Long, lnIDE As Long, sID As String, lnID As Long
For lnRw = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
lnNS = InStr(1, Cells(lnRw, 1).Value, ", ")
lnNE = InStr(lnNS, Cells(lnRw, 1).Value, " - ")
lnIDS = InStr(lnNE, Cells(lnRw, 1).Value, "(") + 1
lnIDE = InStr(lnIDS, Cells(lnRw, 1).Value, ")")
If lnNS * lnNE * lnIDS * lnIDE = 0 Then
Cells(lnRw, 2).Value = "Error in Input"
Else
If IsNumeric(1) Then
Cells(lnRw, 2).Value = Mid(Cells(lnRw, 1).Value, lnIDS, lnIDE - lnIDS)
Cells(lnRw, 1).Value = Mid(Cells(lnRw, 1).Value, lnNS + 2, lnNE - lnNS - 2) & _
"." & Left(Cells(lnRw, 1).Value, lnNS - 1)
Else
Cells(lnRw, 2).Value = "Error in Input"
End If
End If
Next lnRw
End Sub
Don't use integers, don't use worksheet functions where a VBA equivalent exists.
I don't like this, I think name SHOULD be stored Surname first, so I'd maybe go for three fields : ID, Surname, Firstname
It's a bit clunky so you can see where the numbers are used, you could trim the code after if you are confident.