Hi clayts,
You can use the following VBA function to validate the data:
Function Surname(MyInput As String) As Boolean
Surname = True
Dim MyCount As Integer
For MyCount = 1 To Len(MyInput) Step 1
If Asc(Mid(MyInput, MyCount, 1)) > 63 And _
Asc(Mid(MyInput, MyCount, 1)) < 123 Then
Else
If InStr(" '-", Mid(MyInput, MyCount, 1)) > 0 Then
Else
Surname = False
End If
End If
If Surname = False Then
MyCount = Len(MyInput)
End If
Next MyCount
End Function
Unfortunately you can't use user defined functions in Custom Data Valaidation but there is a work around.
If your data is in A1, enter the following in B2 (or any
other cell): = Surname(A1)
Position your cursor on A1 and go to Data, Data Validation and pick Custom under allow and enter =B2 under formula.
The function will evaluate the entry of data and return either a true or false. If False, the data validation will fail and you can display an approitae message (Enter message on Data Validation window under Error Alert Tab).
I've allowed for the following characters in the surname: Space - and '. You can expand this list in the code in the instruction in the list after InStr:
If InStr(" '-", Mid(MyInput, MyCount, 1)) > 0 Then
Hope this helps.
Regards
Fair Cape