Public Function RemoveExtraSpace(inVal As String) As String ' Remove extra spaces from the passed string With CreateObject("VBScript.RegExp") .Pattern = "\s+" .Global = True RemoveExtraSpace = .Replace(inVal, " ") End With End Function