Count number of characters in a cell

This tutorial shows how to count the total number of characters, including spaces, in a cell through the use of an Excel formula or VBA

Example: Count number of characters in a cell

Count number of characters in a cell

METHOD 1. Count number of characters in a cell

EXCEL

=LEN(B5)
This formula uses the Excel LEN function to return the number of characters, including spaces, from a selected cell. In this example we are returning the number of characters in cell B5, which comprises of nine characters, including one space.

METHOD 1. Count number of characters in a cell using VBA

VBA

Sub Count_number_of_characters_in_a_cell()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'count the total number of characters in a cell
ws.Range("C5") = Len(ws.Range("B5"))

End Sub

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code.
Cell Reference: Select the cell that holds the characters that you want to count by changing the cell reference ("B5") in the VBA code.
Worksheet Selection: Select the worksheet which contains the cell from which to count number of characters by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.

Explanation about the formula used to count number of characters in a cell

EXPLANATION

EXPLANATION

This tutorial shows how to count the number of characters, including spaces, in a cell by using of an Excel formula or VBA.
Both the Excel formula and VBA make use of the LEN function to count the number of characters in a cell.
FORMULA
=LEN(text)
ARGUMENTS
text: The string from which to extract the characters.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to count the total number of columns in a range using Excel and VBA methods
How to count the total number of rows in a range using Excel and VBA methods
How to count the total number of numeric characters in a cell using Excel and VBA methods
How to count the total number of cells in a range using Excel and VBA methods
How to count the total number of characters in a cell, excluding spaces, using Excel and VBA methods

RELATED FUNCTIONS

Related Functions Description Related Functions and Description
The Excel LEN function returns the number of characters in a specified string