vba remove leading blank space in string

The solution for “vba remove leading blank space in string” can be found here. The following code will assist you in solving the problem.

Option Explicit
Function trimWhiteSpace(s As String) As String
Dim RE As Object: Set RE = CreateObject(“vbscript.regexp”)
With RE
.Global = True
.MultiLine = True
.Pattern = “^\s*(\S.*\S)\s*”
trimWhiteSpace = .Replace(s, “$1”)
End With
End Function

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts