VBA-Excel: String Functions – RTrim()


The RTrim function removes spaces on the right side of a string.


Rtrim (strMainString)

  • strMainString
    • Mandatory
    • Type: String
    • String whose right space needs to be trimmed.


Function FnRTrim()

    Dim strMainString

    strMainString = "   Sumit Jain  "

     MsgBox "Before : '" & strMainString & "' and after right Space is trimmed. After :'" &                                             RTrim(strMainString) & "'"

End Function 


Also Read About  Other String() Functions

INSTR()                       |                         InstrREV()                       |                        LCase()

UCase()                      |                         Left()                                |                        Right()

LTrim()                        |                         Mid()                                 |                        Trim()

RTrim()                       |                        Replace()                          |                        Space()

Len()                           |                        StrComp()                         |                        String()

Happy Macro­ing :)

Sumit Jain

You may also like...

2 Responses

  1. Jason says:

    “The RTrim func­tion removes spaces on the left side of a string.” <– should be right side of the string.

Leave a Reply to Sumit Jain Cancel reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons
%d bloggers like this: