VBA-Excel: String Functions – Len()


The Len function returns the number of characters in a string including spaces.


Len (strMainString)

  • strMainString
    • Mandatory
    • Type: String
    • String who’s both number of characters to be returned.
Function FnLen()

    Dim strMainString

    strMainString = "   Sumit Jain  "

    MsgBox "No of characters (including spaces) are” & Len(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...

Leave a Reply

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

Show Buttons
Hide Buttons
%d bloggers like this: