Len function VBA – How to check string length

1. Len VBA function – Description

The VBA Len function returns the string length for the given argument. How to use it? All you have to do is enter some text as an argument to the function. The function can be compared to the Length function in other programming languages. The VBA Len function is equivalent to the LEN function in Excel.

2. VBA Len function – Syntax

'officeinside.org 
Linen (string)

String  – The text string for which we want to calculate the number of characters.

Function return : Integer / Numeric value.

3. VBA Len function – Example

How to use Len  function  in VBA Excel? Below is an example of using the Len  function  in the VisualBasic Editor.

'officeinside.org
Sub LenFunctionExample ()

MsgBox Len ("Learning VBA functions")
Range ("A1") = Len ("Learning VBA")
Range ("A2") = "Learn VBA functions"
MsgBox Len (Range ("A2"))

End Sub
Excel VBA functions - Len VBA function
Excel VBA functions – Len VBA function

4. VBA Len function – Where to apply?

The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016.

The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address: VBA functions

Leave a comment

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

%d bloggers like this: