Replaces all multiple spaces / tabs (whitespaces) to single space in a string Sub greedyTrim (Text As String) As String If Text = "" Then Return Text Else Return Regex.Replace("\h+",text," ") End Sub