Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to count number of lines (line breaks) in a cell in Excel?

This article is talking about counting number of lines within a cell in Excel.

Count number of lines in a cell with formulas


Easily split multiline cell contents into rows or columns in Excel

Kutools for Excel's Split Cells utility helps you easily split cell contents by space, comma, new line or other separators into separated rows or columns in Excel. See screenshot:

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 30 days. Free Download Now

doc extract text1


Count number of lines in a cell with formulas


The following formulas can help you to count number of lines in a cell.

1. Select a blank cell, enter formula =LEN(A2)-LEN(SUBSTITUTE(A2,CHAR(10),""))+1 into the Formula Bar, and then press the Enter key. See screenshot:

Note: In the formula, A2 is the cell you need to count a number of lines.

2. Keep selecting the resulting cell, then drag the Fill Handle down to get all line numbers of cells as below screenshot shown.

Notes:

1. For a blank cell, you will get number 1 after applying the above formula.

2. This formula =LEN(A2)-LEN(SUBSTITUTE(A2,CHAR(10),""))+(LEN(A2)>1) can also help you to count a number of lines in a cell but get number 0 of a blank cell.


Related articles:



Recommended Productivity Tools for Excel

Kutools for Excel Helps You Always Finish Work Ahead of Time, and Stand Out From Crowd

  • More than 300 powerful advanced features, designed for 1500 work scenarios, increasing productivity by 70%, give you more time to take care of family and enjoy life.
  • No longer need memorizing formulas and VBA codes, give your brain a rest from now on.
  • Become an Excel expert in 3 minutes, Complicated and repeated operations can be done in seconds, 
  • Reduce thousands of keyboard & mouse operations every day, say goodbye to occupational diseases now.
  • 110,000 highly effective people and 300+ world-renowned companies' choice.
  • 60-day full features free trial. 60-day money back guarantees. 2 years of free upgrade and support.

Brings Tabbed Browsing and Editing to Microsoft Office, Far More Powerful Than The Browser's Tabs

  • Office Tab is designed for Word, Excel, PowerPoint and Other Office Applications: Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Yuka R. · 1 years ago
    with this formula, is there a way to differentiate counting lines with different formatting, e.g. one line with bold, one line with strikethrough etc.? TIA
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Good day,
      Sorry can't handle your problem with this formula. Thanks for your comment.