Se pueden usar expresiones regulares:
Public Function apellidosSafe(str)
Dim result As String
Dim re
Set re = CreateObject("vbscript.regexp")
With re
.IgnoreCase = True
.MultiLine = False
.Global = True
End With
result = Replace(str, "á", "a")
result = Replace(result, "é", "e")
result = Replace(result, "í", "i")
result = Replace(result, "ó", "o")
result = Replace(result, "ú", "u")
result = Replace(result, "ñ", "n")
result = Replace(result, "'", "")
result = Replace(result, "-", "")
re.Pattern = "^de las ": result = re.Replace(result, "delas")
re.Pattern = "^de los ": result = re.Replace(result, "delos")
re.Pattern = "^de la ": result = re.Replace(result, "dela")
re.Pattern = "^del ": result = re.Replace(result, "del")
re.Pattern = "^de ": result = re.Replace(result, "de")
re.Pattern = "^la ": result = re.Replace(result, "la")
apellidosSafe = result
End Function
en este caso, trata de uniformizar una cadena que contiene un apellido latino, quitando los caracteres especiales y juntando algunas de las palabras