How to use the VBA LTRIM Function (Syntax + Example)

HomeVBA Functions LIST (Category Wise)How to use the VBA LTRIM Function (Syntax + Example)

The VBA LTRIM function is listed under the text category of VBA functions. When you use it in a VBA code, it can remove the leading spaces from the string supplied. In simple words, it can remove all those unwanted leading spaces from a string.

Syntax

LTrim(String)

Arguments

  • String: The text string from which you want to remove the leading spaces.

Example

To practically understand how to use VBA LTRIM function, you need to go through the below example where we have written a vba code by using it:

Sub example_LTRIM()
Range("B1").Value = LTrim(Range("A1"))
End Sub

In the above code, we have used the LTRIM function to remove the unwanted spaces from the left side of the cell A1.

Notes

  • If the supplied string is NULL, then it will return NULL in the result.

Related Functions

FORMAT | INSTR | INSTRREV | LCASE | LEFT | LEN | MID | REPLACE | RIGHT | RTRIM | SPACE | STRCOMP | STRCONV | STRING | STRREVERSE | TRIM | UCASE