Last Updated on January 11, 2023 by token
1. LTrim VBA function – Description
LTrim VBA function removes spaces from left side of text. We use it when we want to remove unnecessary spaces from the left side of a text string. If we want to remove spaces from the middle of the text, we should use the VBA Replace function . If, however, we would like to remove spaces from the right side of the text, we should use the RTrim function . To remove unnecessary spaces from both the left and right side of the text, we should use the VBA Trim function .
2. VBA LTrim function – Syntax
String – The text string from which we want to remove unnecessary spaces from the left side.
Function return : String / text value.
3. VBA LTrim function – Example
How to use LTrim function in VBA Excel? Below is an example of using the LTrim function in the VisualBasic Editor.
Sub LTrimExample () MsgBox LTrim ("Free text with spaces on both sides") Range ("A1") = LTrim ("Any text with spaces on both sides") End Sub
4. LTrim VBA function – Where to use?
The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365.
The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions