---
title: "How to Use the LEN Function in Excel — Griddy"
description: "LEN counts characters in Excel. Use it to audit invoice IDs, product codes, imported text, and fields that need a fixed length."
canonical_url: "https://getgriddy.ai/blog/how-to-use-len-function-in-excel/"
---

[Blog](https://getgriddy.ai/blog/)/Excel

Excel

# How to Use the LEN Function in Excel

LEN counts characters in Excel. Use it to audit invoice IDs, product codes, imported text, and fields that need a fixed length.

Do this with AI

[Try Griddy free](https://app.getgriddy.ai/login?mode=register&next=%2F)

Start in your browser. Also works with Excel and Google Sheets.

[By Justin Freels](https://getgriddy.ai/about/)/Updated August 20, 2026/5 min read

LEN counts how many characters are in a cell. It counts letters, numbers, spaces, punctuation, and hidden extra spaces that are easy to miss by eye.

That makes it useful for checking IDs, cleaning imported data, validating codes, and finding text fields that are too long for a system upload.

## The syntax

fx

`=LEN(text)`

- **text** - the cell or text value you want to count

If `A2` contains `INV-1048`, this formula returns `8`:

fx

`=LEN(A2)`

## Example: check invoice IDs before upload

Suppose invoice IDs must be exactly eight characters long. Column A contains the IDs you plan to upload.

**Step 1. Count the characters**

In `B2`, enter:

fx

`=LEN(A2)`

Fill the formula down the column.

**Step 2. Flag the rows that need review**

In `C2`, enter:

fx

`=IF(LEN(A2)=8, "OK", "Check")`

Rows marked `Check` may have missing digits, extra spaces, or a copied value that does not match the required format.

**Step 3. Clean before counting if spaces are not meaningful**

If leading or trailing spaces should not count, wrap the value in TRIM:

fx

`=LEN(TRIM(A2))`

That gives you the length of the cleaned value instead of the raw cell.

TIP

Use `LEN(A2)` and `LEN(TRIM(A2))` side by side when you suspect hidden spaces. If the counts differ, the cell needs cleanup.

## LEN counts spaces

This surprises people because spaces are hard to see. These two values are different to LEN:

```
Acme
Acme
```

The second value has a trailing space, so LEN returns one extra character.

That matters when you are debugging failed lookups. Two customer names can look the same on screen while one carries a hidden trailing space from an export.

## Common uses for LEN

| Use case | Formula pattern |
| --- | --- |
| Check fixed-length IDs | `=LEN(A2)=8` |
| Find values with hidden spaces | `=LEN(A2)-LEN(TRIM(A2))` |
| Flag long notes | `=IF(LEN(A2)>250, "Too long", "OK")` |
| Count cleaned text | `=LEN(TRIM(A2))` |

## LEN vs counting words

LEN counts characters, not words. If a cell contains a sentence, LEN tells you how long the sentence is, including spaces and punctuation.

For most spreadsheet work, that is enough. Use it to validate text fields, not to analyze writing style.

## The Griddy way

Length checks are easy for one column and annoying across a whole import.

> "Flag invoice IDs that are not exactly eight characters and show which ones have hidden spaces"

Griddy can add the LEN checks, compare raw and cleaned values, and mark the rows that need review before the file goes into another system.

## Validate before export

A length check is most useful when it is explicit about what “valid” means. For a fixed-width identifier, compare `LEN` with the required count and return a clear status:

fx

`=IF(LEN(A2)=8,"OK","Review")`

If spaces may have been pasted around the value, check both the raw and cleaned lengths rather than silently changing the source:

fx

`=LEN(A2)-LEN(TRIM(A2))`

That second formula shows how many ordinary spaces were removed. `LEN` counts spaces, but it does not tell you whether a character is visually obvious. Keep the original column, create a cleaned or validation column, and review exceptions before importing the file. This makes the audit reversible and prevents a formula from hiding a bad identifier.

## Sources

- [Microsoft Support: LEN and LENB functions](https://support.microsoft.com/en-us/office/len-lenb-functions-29236f94-cedc-429d-affd-b5e33d2c67cb)
- [Microsoft Support: LEN function](https://support.microsoft.com/en-us/excel/functions/len-function)

Do this with AI

## Turn the instructions into a finished spreadsheet.

Tell Griddy what you need in plain English, then inspect and keep editing the result in the browser, Excel, or Google Sheets.

[Try Griddy free](https://app.getgriddy.ai/login?mode=register&next=%2F)Start in your browser. No download required.

Also works with[Excel](https://appsource.microsoft.com/en-us/product/office/wa200008745)[Google Sheets](https://workspace.google.com/marketplace/app/griddy/206105793696)

[All posts](https://getgriddy.ai/blog/)

Do this with AI

## Ask Griddy to do this for you.

Describe the result in plain English—no formula knowledge required.

[Try Griddy free](https://app.getgriddy.ai/login?mode=register&next=%2F)Start in your browser. No download required.

Also works with[Excel](https://appsource.microsoft.com/en-us/product/office/wa200008745)[Google Sheets](https://workspace.google.com/marketplace/app/griddy/206105793696)

About this guide

Written by Justin Freels, Founder, Griddy.

Updated August 20, 2026/5 min read
