search
HomeSoftware TutorialOffice SoftwareExcel LEN function: count characters in cell

Are you looking for an Excel formula to count characters in a cell? If so, then you have certainly landed up on the right page. This short tutorial will teach you how you can use the LEN function to count characters in Excel, with or without spaces.

Of all Excel functions, LEN is arguably the easiest and most straightforward one. The name of the function is easy to remember, it's nothing else but the first 3 characters of the word "length". And it is what the LEN function actually does - returns the length of a text string, or length of a cell.

To put it differently, you use the LEN function in Excel to count all characters in a cell, including letters, numbers, special characters, and all spaces.

In this short tutorial, we are going to cast a quick look at the syntax first, and then have a closer look at some useful formula examples to count characters in your Excel worksheets.

Excel LEN function

The LEN function in Excel counts all characters in a cell, and returns the string length. It has just one argument, which is obviously required:

=LEN(text)

Where text is the text string for which you want to count the number of characters. Nothing could be easier, right?

Below you will find a couple of simple formulas to get the basic idea of what the Excel LEN function does.

=LEN(123) - returns 3, because 3 numbers are supplied to the text argument.

=LEN("good") - returns 4, because the word good contains 4 letters. Like any other Excel formula, LEN requires enclosing text strings double quotes, which are not counted.

In your real-life LEN formulas, you are likely to supply cell references rather than numbers or text strings, to count characters in a specific cell or a range of cells.

For instance, to get the length of text in cell A1, you'd use this formula:

=LEN(A1)

More meaningful examples with detailed explanations and screenshots follow below.

How to use LEN function in Excel - formula examples

At first sight, the LEN function looks so simple that hardly requires any further explanation. However, there are some useful tricks that could help you tweak your Excel Len formula for your specific needs.

How to count all characters in a cell (including spaces)

As already mentioned, the Excel LEN function counts absolutely all characters in a specified cell, including all spaces - leading, trailing spaces, and spaces between words.

For example, to get the length of cell A2, you use this formula:

=LEN(A2)

As shown in the below screenshot, our LEN formula counted 36 characters including 29 letters, 1 number, and 6 spaces.

Excel LEN function: count characters in cell

Count characters in multiple cells

To count characters in multiple cells, select the cell with your Len formula and copy it to other cells, for example by dragging the fill handle. For the detailed instructions, please see How to copy formula in Excel.

As soon as the formula is copied, the LEN function will return the character count for each cell individually.

And again, let me draw your attention that the LEN function counts absolutely everything including letters, numbers, spaces, commas, quotes, apostrophes, and so on:

Excel LEN function: count characters in cell

Note. When copying a formula down the column, be sure to use a relative cell reference like LEN(A1), or a mixed reference like LEN($A1) that fixes only the column, so that your Len formula will properly adjust for the new location. For more information, please check out Using absolute and relative cell references in Excel.

Count a total number of characters in several cells

The most obvious way to get the total number of characters in several cells is add up a few LEN functions, for example:

=LEN(A2) LEN(A3) LEN(A4)

Or, use the SUM function to total the character counts returned by LEN formulas:

=SUM(LEN(A2), LEN(A3), LEN(A4))

Either way, the formula counts the characters in each of the specified cells and returns the total string length:

Excel LEN function: count characters in cell

This approach is undoubtedly easy-to-understand and easy-to-use, but it's not the best way to count characters in a range consisting of, say, 100 or 1000 cells. In this case, you'd better use the SUMPRODUCT and LEN functions together like shown in this example.

How to count characters excluding leading and trailing spaces

When working with big worksheets, a common problem is leading or trailing spaces, i.e. extra spaces at the beginning or at the end of the items. You would hardly notice them on the sheet, but after you've faced them a couple of times, you learn to beware of them.

If you suspect there are a few invisible spaces in your cells, the Excel LEN function is a great help. As you remember, it includes all spaces in a character count:

Excel LEN function: count characters in cell

To get the string length without leading and trailing spaces, simply embed the TRIM function in your Excel LEN formula:

=LEN(TRIM(A2))

Excel LEN function: count characters in cell

How to count the number of characters in a cell excluding all spaces

If your aim is to get the character count without any spaces whether leading, trailing or in-between, you would need a bit more complex formula:

=LEN(SUBSTITUTE(A2," ",""))

Excel LEN function: count characters in cell

As you probably know, the SUBSTITUTE function replaces one character with another. In the above formula, you replace a space (" ") with nothing, i.e. with an empty text string (""). And because you embed SUBSTITUTE in the LEN function, the substitution is not actually made in cells, it just instructs your LEN formula to calculate the length of string without any spaces.

You can find a more detailed explanation of the Excel SUBSTITUTE function here: Most popular Excel functions with formula examples.

How to count number of characters before or after a given character

Occasionally, you may need to know the length of a certain part of a text string, rather than count the total number of characters in a cell.

Supposing, you have a list of SKUs like this:

Excel LEN function: count characters in cell

And all valid SKUs have exactly 5 characters in the first group. How do you spot invalid items? Yep, by counting the number of characters before the first dash.

So, our Excel length formula goes as follows:

=LEN(LEFT($A2, SEARCH("-", $A2)-1))

Excel LEN function: count characters in cell

And now, let's break down the formula so that you can understand its logic.

  • You use the SEARCH function to return the position of the first dash ("-") in A2: SEARCH("-", $A2)
  • Then, you use the LEFT function to return that many characters starting on the left side of a text string, and subtract 1 from the result because you don't want to include the dash: LEFT($A2, SEARCH("-", $A2,1)-1))
  • And finally, you have the LEN function to return the length of that string.

As soon as the character count is there, you may want to take a step further, and highlight invalid SKUs by setting up a simple conditional formatting rule with a formula like =$B25:

Excel LEN function: count characters in cell

Or, you can identify invalid SKUs by embedding the above LEN formula in the IF function:

=IF(LEN(LEFT($A2, SEARCH("-", $A2)-1))5, "Invalid", "")

As demonstrated in the below screenshot, the formula perfectly identifies invalid SKUs based on a string length, and you don't even need a separate character count column:

Excel LEN function: count characters in cell

In a similar manner, you can use the Excel LEN function to count the number of characters after a specific character.

For example, in a list of names, you may want to know how many characters the Last Name contains. The following LEN formula does the trick:

=LEN(RIGHT(A2,LEN(A2)-SEARCH(" ",A2)))

Excel LEN function: count characters in cell

How the formula works:

  • First, you determine the position of a space (" ") in a text string by using the SEARCH function: SEARCH(" ",A2)))
  • Then, you calculate how many characters follow the space. For this, you subtract the space position from the total string length: LEN(A2)-SEARCH(" ",A2)))
  • After that, you have the RIGHT function to return all characters after the space.
  • And finally, you use the LEN function to get the length of string returned by the RIGHT function.

Please note, for the formula to work correctly, each cell should contain just one space, i.e. only the First and Last name, with no middle names, titles or suffixes.

Well, this is how you use LEN formulas in Excel. In the next article, we are going to explorer other capabilities of the Excel LEN function, and you will learn a few more useful formulas to count characters in Excel cells and ranges. In the meantime, I thank you for reading and hope to see you on our blog soon!

Practice workbook for download

Excel LEN - formula examples (.xlsx file)

The above is the detailed content of Excel LEN function: count characters in cell. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to convert number to text in Excel - 4 quick waysHow to convert number to text in Excel - 4 quick waysMay 15, 2025 am 10:10 AM

This tutorial shows how to convert numbers to text in Excel 2016, 2013, and 2010. Learn how to do this using Excel's TEXT function and use numbers to strings to specify the format. Learn how to change the format of numbers to text using the Format Cell… and Text to Column options. If you use an Excel spreadsheet to store long or short numbers, you may want to convert them to text one day. There may be different reasons to change the number stored as a number to text. Here is why you might need to have Excel treat the entered number as text instead of numbers: Search by part rather than the whole number. For example, you might want to find all numbers containing 50, such as 501

How to make a dependent (cascading) drop-down list in ExcelHow to make a dependent (cascading) drop-down list in ExcelMay 15, 2025 am 09:48 AM

We recently delved into the basics of Excel Data Validation, exploring how to set up a straightforward drop-down list using a comma-separated list, cell range, or named range.In today's session, we'll delve deeper into this functionality, focusing on

How to create drop down list in Excel: dynamic, editable, searchableHow to create drop down list in Excel: dynamic, editable, searchableMay 15, 2025 am 09:47 AM

This tutorial shows simple steps to create a drop-down list in Excel: Create from cell ranges, named ranges, Excel tables, other worksheets. You will also learn how to make Excel drop-down menus dynamic, editable, and searchable. Microsoft Excel is good at organizing and analyzing complex data. One of its most useful features is the ability to create drop-down menus that allow users to select items from predefined lists. The drop-down menu allows for faster, more accurate and more consistent data entry. This article will show you several different ways to create drop-down menus in Excel. - Excel drop-down list - How to create dropdown list in Excel - From the scope - From the naming range

Convert PDF to Excel manually or using online convertersConvert PDF to Excel manually or using online convertersMay 15, 2025 am 09:40 AM

The PDF format, known for its ability to display documents independently of the user's software, hardware, or operating system, has become the standard for electronic file sharing.When requesting information, it's common to receive a well-formatted P

How to convert Excel files to PDFHow to convert Excel files to PDFMay 15, 2025 am 09:37 AM

This short tutorial describes 4 possible ways to convert Excel files to PDF - using Excel's Save As feature, Adobe software, online Excel to PDF converter, and desktop tools. Converting an Excel worksheet to a PDF is usually necessary if you want other users to be able to view your data but can't edit it. You may also want to convert Excel spreadsheets to PDF format for use in media toolkits, presentations, and reports, or create a file that all users can open and read even if they don't have Microsoft Excel installed, such as on a tablet or phone. Today, PDF is undoubtedly one of the most popular file formats. According to Google

How to use SUMIF function in Excel with formula examplesHow to use SUMIF function in Excel with formula examplesMay 13, 2025 am 10:53 AM

This tutorial explains the Excel SUMIF function in plain English. The main focus is on real-life formula examples with all kinds of criteria including text, numbers, dates, wildcards, blanks and non-blanks. Microsoft Excel has a handful o

IF function in Excel: formula examples for text, numbers, dates, blanksIF function in Excel: formula examples for text, numbers, dates, blanksMay 13, 2025 am 10:50 AM

In this article, you will learn how to build an Excel IF statement for different types of values as well as how to create multiple IF statements. IF is one of the most popular and useful functions in Excel. Generally, you use an IF statem

How to sum a column in Excel - 5 easy waysHow to sum a column in Excel - 5 easy waysMay 13, 2025 am 09:53 AM

This tutorial shows how to sum a column in Excel 2010 - 2016. Try out 5 different ways to total columns: find the sum of the selected cells on the Status bar, use AutoSum in Excel to sum all or only filtered cells, employ the SUM function

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.