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

or
0
0
0
s2smodern

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 120 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

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 200 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
People in conversation:
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Yuka R. · 3 months 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 · 2 months ago
      Good day,
      Sorry can't handle your problem with this formula. Thanks for your comment.