VBA Substrings Use Trim to get a copy of the string without any leading or trailing spaces


Example

'Trim the leading and trailing spaces in a string
Const paddedText As String = "    Foo Bar    "
Dim trimmedText As String
trimmedText = Trim$(paddedText)
'trimmedText = "Foo Bar"