Public Function ProperCelt(sText As String) As String 'Author: © Copyright 2001 Pacific Database Pty Limited ' Graham R Seach gseach@pacificdb.com.au ' Phone: +61 2 9872 9594 Fax: +61 2 9872 9593 ' ' You may freely use and distribute this code ' with any applications you may develop, on the ' condition that the copyright notice remains ' unchanged, and intact as part of the code. You ' may not sell or publish this code in any form ' without the express written permission of the ' copyright holder. ' 'Description: This function converts a text string ' to proper case (the first character of every word ' to uppercase), taking account of celtic names, like ' O'Donnel, McKinnen and D'Angelo (although that's not ' Celtic). It also takes into account hyphenated names, ' like McKenzie-Jones. ' 'Inputs: sText: The string to be converted. ' 'Outputs: If a string is supplied, the string is ' returned. If no string is supplied, a zero-length ' string is returned. Dim iLPos As Integer Dim iRPos As Integer Dim sWord As String Dim sTemp As String If Len(sText) = 0 Then Exit Function sText = StrConv(sText, vbProperCase) iLPos = 1 While (iLPos > 0) And (iLPos < Len(sText)) iRPos = InStr(iLPos + 1, sText, " ") If iRPos = 0 Then iRPos = Len(sText) sWord = Trim(Mid(sText, iLPos, (iRPos - iLPos + 1))) If Left(sWord, 2) = "Mc" Or Left(sWord, 2) = "O'" Or _ Left(sWord, 2) = "D'" Then If Len(sWord) > 2 Then sWord = Left(sWord, 2) & UCase(Mid(sWord, 3, 1)) & _ Right(sWord, Len(sWord) - 3) End If End If iLPos = InStr(1, sWord, "-") If iLPos > 0 Then sWord = Left(sWord, iLPos) & UCase(Mid(sWord, iLPos + 1, 1)) & _ Mid(sWord, iLPos + 2) End If sTemp = sTemp & " " & sWord iLPos = InStr(iRPos, sText, " ") Wend ProperCelt = Trim(sTemp) End Function