Home Privacy Policy Feedback Link to us Site Map Forums

Excel: RTrim Function (VBA only)


In Excel, the RTrim function removes trailing spaces from a string.

The syntax for the RTrim function is:

RTrim( text )

text is the string that you wish to remove trailing spaces from.


Applies To:

  • Excel 2007, Excel 2003, Excel XP, Excel 2000

For example:

RTrim("Tech on the Net  ") would return "Tech on the Net"
RTrim("  Alphabet  ") would return "  Alphabet"

VBA Code

The RTrim function can only be used in VBA code. For example:

Dim LResult As String

LResult = RTrim("   Alphabet   ")

The variable LResult would now contain the value of "   Alphabet".