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

'       To use this function code :
 
	myString = RemoveExtraSpace(myString) 

End Function