VBA LTrim function

LTrim Function Description

The VBA LTrim function removes leading whitespaces from a string, looking from the left side of the string.

To remove trailing whitespaces see RTrim, to remove both trailing and leading whitespaces see Trim.

Syntax

The syntax for the LTrim function in VBA is:

LTrim( text )

Parameters

text
The string for which you wish to remove any leading (looking from the left) whitespaces from.

Other Notes

LTrim does not remove non-whitespace characters such as new lines (vbNewLine, vbCrLf) etc.

Example usage

The LTrim function can be used in VBA code. Let’s look at some VBA LTrim function examples:

LTrim "   Hello world!"
'Result: "Hello world!"

LTrim " " & vbNewLine & " Some Text"
'Result: vbNewLine & " Some Text"