VBA – Trim String
The Trim function in VBA is used to remove all leading and trailing spaces from a string.
Trim
Syntax:
Trim(string)
Parameter:
Return Value:
Example
Dim str1 As String Dim trimmedStr As String str1 = " Hello, World! " trimmedStr = Trim(str1) ' trimmedStr will be "Hello, World!"
Use Cases:
Key Considerations: