Be the first user to complete this post

  • 0
Add to List

VBA-Excel: String Functions – Trim()

Description: 

The Trim function removes spaces on the left and right side of a string.

Format:

Trim (strMainString)

Arguments:
  • strMainString
    • Mandatory
    • 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()                       |                         InstrREV()                       |                        LCase()

UCase()                      |                         Left()                                |                        Right()

LTrim()                        |                         Mid()                                 |                        Trim()

RTrim()                       |                        Replace()                          |                        Space()

Len()                           |                        StrComp()                         |                        String()



Also Read:

  1. VBA Excel - Cells, Ranges and Offset : Range
  2. VBA-Excel: String Functions – LTrim()
  3. VBA-Excel: Date-Time Functions – Day()
  4. VBA-Excel: Array Functions – Join() – Converts Array to String
  5. VBA-Excel: Arrays – Multi Dimensional Array
  6. VBA-Excel: String Functions – Len()
  7. VBA Excel – Refer to Multiple Ranges : Union Method
  8. VBA-Excel: Date-Time Functions – FormatDateTime()