VBA-Excel: String Functions – Trim()

VBA-Excel: String Functions – Trim()

Description: 

The Trim func­tion removes spaces on the left and right side of a string.

Format:

Trim (str­Main­String)

Arguments:
  • str­Main­String
    • Manda­tory
    • Type: String
    • String whose both side spaces needs to be trimmed.

 

Function FnTrim()

   Dim strMainString

   strMainString = "   Sumit Jain  "

   MsgBox "Hello" & Trim(strMainString) & "Trimmed both sides."

End Function
Trim

Trim

Also Read About  Other String() Functions

INSTR()                       |                         Instr­REV()                       |                        LCase()

UCase()                      |                         Left()                                |                        Right()

LTrim()                        |                         Mid()                                 |                        Trim()

RTrim()                       |                        Replace()                          |                        Space()

Len()                           |                        Str­Comp()                         |                        String()

Happy Macro­ing :)

Sumit Jain

 

2 thoughts on “VBA-Excel: String Functions – Trim()

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

%d bloggers like this: