How to Add a Line in Excel

To add a line of data in Excel, right-click the row number below where you want the new line and choose Insert. Excel adds a blank row above it and shifts everything underneath down one row. If you meant a different kind of line, such as a second line of text inside a cell, a border under a total, a drawn line or arrow, or a line on a chart, pick it from the list below and jump to that section.

Applies to: Excel for Microsoft 365 (Windows and Mac), Excel 2024, Excel 2021, Excel 2019, Excel 2016 and Excel for the web. Menu names below are from Excel for Microsoft 365 on Windows 11; the Mac and web versions use the same ribbon tabs, with small differences noted where they matter.

Which line do you mean?

Match what you want to the right tool:

  • A new row for more data (for example, a new expense between two existing ones): insert a row.
  • Two lines of text in one cell (for example, a street address over a city): start a new line inside the cell.
  • A line that belongs to the cells (a rule under the headings, a double line above a total, a box around a range): add a border.
  • A free-floating line or arrow (pointing at a number, connecting two boxes in a simple diagram): draw a line shape.
  • A line on a chart (a trendline, an average or target line, or a whole line graph): add a chart line.

If you’re not sure between a border and a drawn line, use a border. Borders print with your data, move when you sort or insert rows, and never drift out of place.

Add a new row (a line of data)

A new row always appears above the row you select, so click the row that should end up just below your new line. In this example, Alex’s monthly budget has Rent in row 4 and Utilities in row 5, and a new Internet line needs to go between them.

  1. Select the row. Click the row number 5 on the left edge of the sheet. The whole row is highlighted.
  2. Open the shortcut menu. Right-click the highlighted row number.
Right-click menu on Excel row number 5 with the Insert command highlighted
Select row number 5 and choose Insert. The new row appears above Utilities. This recreation uses a fictional budget and a focused shortcut-menu excerpt.
  1. Choose Insert. Excel adds an empty row 5, and Utilities moves down to row 6. Because you selected an entire row, Excel doesn’t ask which direction to shift cells.
  2. Type your data. Click cell A5 and enter Internet, then press Tab and enter the amount in B5.
New Internet row inserted in an Excel budget with the Insert Options menu open and the total formula expanded to row 6
After adding Internet (75), Utilities moves to row 6 and Total becomes 1,925 using =SUM(B2:B6). The separately labelled Insert Options detail shows the formatting choices immediately after insertion; it represents an earlier moment.

The new row picks up the formatting of the row above it. To change that, click the small Insert Options paintbrush button that appears next to the new row and choose Format Same As Below or Clear Formatting. Microsoft explains this button, along with the matching steps for columns, in its page on inserting or deleting rows and columns in Excel.

Other ways to insert a row

  • From the ribbon: Click any cell in the row, then go to Home > Insert > Insert Sheet Rows.
  • With the keyboard (Windows): Press Shift + Space to select the current row, then press Ctrl + Shift + + (the plus key). If only a single cell is selected when you press Ctrl + Shift + +, Excel opens an Insert box instead; choose Entire row and click OK.
  • On a Mac: Control-click (or two-finger click) the row number and choose Insert, or use Home > Insert > Insert Sheet Rows.
  • Several rows at once: Drag across as many row numbers as you want new rows (for example, rows 5 through 7 for three new rows), then right-click and choose Insert.

Add a row to an Excel table

If your data is formatted as a table (it has banded colors and filter arrows in the header, and a Table Design tab appears when you click inside it), you have two extra options:

  • Click the last cell of the table and press Tab. A new row appears at the bottom with the same formatting and formulas.
  • Right-click a cell inside the table and choose Insert > Table Rows Above. Only the table gets a new row, so data beside the table isn’t split.

Need a gap after every record, or dozens of blank rows at once? This guide on inserting blank rows in Excel covers those bigger jobs.

What happens to your formulas

Excel updates cell references when rows move, so a formula that pointed at Utilities in B5 now points at B6. A total such as =SUM(B2:B10) grows to =SUM(B2:B11) when you insert a row anywhere between rows 2 and 10. Inserting a row directly below the last row of a range is the one spot to watch: the SUM may not stretch to include it, so click the total afterward and check the range in the formula bar. Converting the data to a table with Ctrl + T avoids the problem, because table formulas and totals extend as rows are added.

Start a new line inside a cell

Pressing Enter in Excel moves you to the next cell, so you need a different key combination to break a line of text inside the same cell.

  1. Double-click the cell, or select it and press F2, so you’re editing it. You’ll see a blinking cursor in the text.
  2. Click the spot in the text where the second line should start.
  3. Press Alt + Enter on Windows or in Excel for the web on a PC. On a Mac, press Control + Option + Return (in many recent versions Option + Return also works).
  4. Press Enter to finish editing.

Excel usually turns on Wrap Text for you, and the row gets taller to show both lines. In a formula, use CHAR(10) as the line break, for example =A2&CHAR(10)&B2 to put Jordan’s street on one line and city on the next, then select the cell and click Home > Wrap Text; without Wrap Text, the break is there but invisible. Mobile steps, removing line breaks, and more formula examples are in this walkthrough on adding a line break in an Excel cell.

Add a border line under or around cells

A border is a line attached to the edge of a cell. It’s the right choice for a line under column headings, a single line above a total, or a double line under a grand total.

  1. Select the cells that should get the line, for example B4:E4 for a row of headings.
  2. On the Home tab, in the Font group, click the small arrow beside the Borders button (it looks like a square divided into four).
  3. Choose a style: Bottom Border for a thin line, Thick Bottom Border for a heavier one, or Bottom Double Border for the accounting-style double line under a total. All Borders outlines every cell in the selection, and Outside Borders draws a box around the whole range.
Excel Borders menu open on the Home tab showing Bottom Border, Thick Bottom Border and Bottom Double Border
The Home → Borders menu includes Bottom Border, Bottom Double Border, and Thick Bottom Border. Draw Borders contains Line Color and Line Style. This recreated sample has B2:B5 selected; no borders were applied.

The line appears as soon as you click, and the Borders button remembers that choice for the next range.

Change the color, thickness or angle

  • Line color and Line style: At the bottom of the Borders menu, under Draw Borders, pick a color and a style (dashed, dotted, thick, double). Then choose Draw Border and click or drag along cell edges to paint lines exactly where you want them. Press Esc when you’re done.
  • Diagonal line across a cell: Choose More Borders (or press Ctrl + 1 and open the Border tab). The two diagonal buttons in the lower corners of the preview draw a line from corner to corner, which is common in the top-left cell of a schedule.
  • Remove a border: Select the cells and choose No Border, or use Erase Border to remove individual lines.

Microsoft’s page on applying or removing cell borders lists every preset style. The faint gray grid you see on every sheet is different: those are gridlines, which are display-only and don’t print by default. To print the full grid instead of adding borders, check Page Layout > Sheet Options > Gridlines > Print.

Draw a line or arrow shape

A line shape floats on top of the sheet, so it can go anywhere, at any angle, and it doesn’t change your data. Use it for callouts, arrows, and simple diagrams.

  1. Go to Insert > Illustrations > Shapes. (On a narrow window, Shapes may sit inside an Illustrations button.)
  2. Under Lines, pick a straight line, an arrow, a double arrow, an elbow or curved connector, a curve, or a freeform line. Your pointer turns into a thin cross.
Excel Shapes gallery open on the Insert tab with the Lines group highlighted
Open Insert → Illustrations → Shapes for the Lines group. Right-clicking a line offers Lock Drawing Mode. This focused gallery and shortcut menu are recreated; no shape was drawn.
  1. Click where the line should start and drag to where it should end. Hold Shift while dragging to keep it perfectly horizontal, vertical, or at a 45-degree angle. Holding Alt on Windows makes the ends snap to cell edges, which helps a line sit exactly under a row.
  2. Release the mouse. The line stays selected, with a round handle at each end and the Shape Format tab open.
  3. Use Shape Format > Shape Outline to change the color, Weight (thickness), Dashes, or Arrows.

To draw several lines in a row without going back to the menu, right-click a line in the Shapes gallery and choose Lock Drawing Mode; press Esc when you’re finished. Connectors stay attached to two shapes when you move them, which suits simple diagrams.

Each shape has a setting that controls whether it follows the cells underneath when you insert rows or resize columns. To change it, right-click the line, choose Format Shape, open Size & Properties, and under Properties choose Move and size with cells or Don’t move or size with cells. Shapes don’t sort or filter with your data, which is the main reason to prefer a border for lines that belong to a table.

Add a line to a chart

Lines on charts come in three flavors, and each one has its own route:

  • Trendline: Click the chart, click the + (Chart Elements) button at its top-right corner, and check Trendline. On a Mac, or if you don’t see the + button, use Chart Design > Add Chart Element > Trendline. Trendlines work on column, bar, line and scatter charts, but not on pie, doughnut, stacked or 3-D charts. For scatter plots, the guide to adding a line of best fit in Excel shows how to display the equation and R-squared value.
  • Average, target or goal line: Add a helper column that repeats the value on every row (for example, =AVERAGE($B$2:$B$13) filled down), add that column to the chart as a new series, then right-click the series, choose Change Series Chart Type, and set it to Line. Because it’s built from cells, the line updates when your numbers change, which a hand-drawn line can’t do. The full process, with formatting tips, is in adding an average line to an Excel chart.
  • A line graph of your data: Select the data, including headings, and go to Insert > Charts > Insert Line or Area Chart, then pick Line or Line with Markers.

When a line won’t go in

Insert is grayed out

Three things usually cause this. You may still be editing a cell (press Esc first). The sheet may be protected (check Review > Unprotect Sheet; you’ll need the password if one was set). Or the workbook may be open in a read-only or Protected View window, in which case click Enable Editing in the yellow bar.

“Microsoft Excel can’t insert new cells because it would push non-empty cells off the end of the worksheet”

A sheet has a fixed 1,048,576 rows, so the last row must be empty before you can insert one. Something down there, often formatting applied to entire columns, a stray space, or a formula filled too far, is in the way. Press Ctrl + End to see where Excel thinks your data ends. If that’s far below your real data, select the first empty row under your data, press Ctrl + Shift + Down Arrow to select everything to the bottom, right-click, choose Delete, then save, close and reopen the workbook before inserting again.

Alt + Enter didn’t make a second line

Make sure you’re editing the cell (you should see a blinking cursor) before pressing the keys. If the text still shows on one line, turn on Home > Wrap Text and use Home > Format > AutoFit Row Height; a row height set by hand stays fixed and can hide the second line.

A drawn line is slightly crooked or in the wrong place

Select it and, for a horizontal line, set the height to 0 in Shape Format > Size; for a vertical line, set the width to 0. Use the arrow keys to nudge a selected line into place.

Check your work and undo a line

  • New row: The row numbers stay in sequence and the data you moved now sits one row lower. Click a total and look at the formula bar to confirm it includes the new row.
  • Border or shape: Open File > Print to see the line as it will print, without the gridlines.
  • Undo: Press Ctrl + Z (Command + Z on a Mac) right away. Later, right-click a row number and choose Delete to remove an inserted row, choose No Border to clear a border, or click a shape and press Delete.

Cleaning up lines you didn’t add, such as gridlines, page break lines or leftover borders, is a separate job covered in how to remove lines in Excel.

FAQs

How do I add a line through the middle of text, like crossing off a finished task?

That’s strikethrough, not a border. Select the cell and press Ctrl + 5 on Windows, or open Format Cells (Ctrl + 1) and check Strikethrough on the Font tab. Press the same shortcut again to remove it.

Can I add a line below every row automatically?

Yes. Select the whole data range and choose All Borders from the Borders menu, or format the range as a table with Home > Format as Table and pick a style with row lines. Rows you add later inside the table get the same lines.

How do I underline text in a cell instead of adding a border?

Press Ctrl + U (Command + U on a Mac). An underline only runs under the characters, while a bottom border runs the full width of the cell. For financial reports, Format Cells > Font > Underline also offers Single Accounting and Double Accounting, which extend almost the width of the cell.

Once your lines are in, a good next step is to keep your headings in view as the list grows: select the row under your headings and choose View > Freeze Panes > Freeze Panes.