View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Need Period After Initials

Susan,

If your name strings could have 2 or more initials rather than just one:

Susan A B Smith

then this UDF will work, used like:

=MidInit(A1)

Function MidInit(myName As String) As String
Dim i As Integer
Dim myStr As String

myStr = myName
For i = 1 To Len(myName) - 2
If Mid(myName, i, 1) = " " And Mid(myName, i + 2, 1) = " " Then
myStr = Left(myName, i + 1) & "." & Mid(myName, i + 2, Len(myName))
myStr = MidInit(myStr)
End If
Next i

MidInit = myStr
End Function

HTH,
Bernie
MS Excel MVP


"Susan" wrote in message
...
I imported a database into an Excel spreadsheet. The middle initials in the
names don't have periods after them. Is there a wildcard character that I
can use to replace initials without periods to initials with periods?