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