VBA LTrim function

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

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"

Simply the best place to learn Excel VBA