LearnExcel.io
Menu

How to Draw a Line in Excel

Written by ··Updated June 16, 2026

To draw a line in Excel, go to Insert → Illustrations → Shapes, pick the straight line (or an arrow or connector), then click and drag on the worksheet. Hold Shift while you drag and the line snaps to a perfect horizontal, vertical, or 45-degree angle. That covers the most common case, but “draw a line” can mean several different things in Excel, so this guide walks through each method and points you to the right one.

First, decide which kind of “line” you need

The phrase “draw a line” hides at least five distinct tasks. Picking the wrong tool is the single biggest reason people get stuck, so match your goal to the method before you start:

  • A floating line drawn on top of the sheet (to point at something, underline a heading, connect two boxes) — use a Shape line. This is what most people mean and what the steps below cover.
  • A line under, over, or through cells (a divider, an underline beneath totals) — use cell borders, not a shape. Borders stick to the grid and move with the cells. See how to add a border in Excel.
  • A line of best fit on a chart — that is a trendline, added from the chart itself. See how to add a trend line in Excel.
  • A line through text (crossing out a word) — that is strikethrough formatting. See how to apply strikethrough in Excel.
  • A tiny in-cell line chart — that is a sparkline, inserted from Insert → Sparklines.

If you wanted a freehand or curved line rather than a straight one, the dedicated guide on drawing in Excel and the broader walkthrough of inserting a line in Excel go deeper on those specific cases.

Draw a straight line shape (Windows and Mac)

This is the standard method and works the same way in Excel for Microsoft 365, Excel 2021/2019/2016, and Excel for Mac.

  1. Open the Insert tab on the ribbon.
  2. In the Illustrations group, click Shapes. (On a narrow window the group collapses to a single “Illustrations” button — click it first.)
  3. Under the Lines heading at the top of the gallery, click the plain straight line (the first icon). Your cursor becomes a crosshair.
  4. Click where the line should start, hold the mouse button, drag to the end point, and release.

To force a perfectly straight line, hold Shift while you drag. Shift constrains the line to the nearest 15-degree increment, which gives you clean horizontal, vertical, and diagonal lines without any wobble. Holding Alt (Windows) or Cmd (Mac) while dragging snaps the endpoints to the cell gridlines, which is handy when you want a line to line up with a column edge.

The Lines section of the gallery also offers arrows (a line with one or two arrowheads), elbow and curved connectors, freeform, and scribble. If you specifically need an arrow, the insert shapes in Excel guide covers the full shape gallery, including how to swap a plain line for an arrow after the fact.

Use connectors that snap to shapes

If you are linking boxes in a diagram, do not use a plain line — use a connector. Connectors are the line types in the second row of the Lines gallery (straight connector, elbow connector, curved connector). When you hover over a shape with a connector tool active, gray connection points appear on the shape’s edges. Click a point on the first shape, drag to a point on the second, and the connector locks to both. Move either shape afterward and the connector stretches and re-routes to stay attached.

Connectors are the backbone of any diagram, which is why they matter most when you create a flowchart in Excel. Pairing connectors with text boxes lets you build labeled diagrams entirely inside a worksheet.

Draw freehand lines with the Draw tab (touch and pen)

On a touchscreen or pen-enabled device, the Draw tab gives you ink pens for freehand lines. If you do not see a Draw tab, right-click the ribbon, choose Customize the Ribbon, and tick Draw in the right-hand list.

  1. Open the Draw tab.
  2. Pick a pen, highlighter, or pencil and choose a thickness and color.
  3. Draw directly on the sheet with your finger, stylus, or mouse.
  4. Excel has an Ink to Shape option that cleans up a roughly drawn straight line into a tidy one automatically.

Ink lines behave like drawn objects and can be erased with the eraser tool on the same tab. On a mouse-only Windows PC the Draw tab still works, but freehand control is much easier with a stylus.

Use cell borders as a line

When you want a line that belongs to the grid — an underline beneath a row of totals, a divider between sections — a border is the right tool, not a shape. Borders never drift, because they are attached to cells rather than floating above them.

  1. Select the cell or range that should carry the line.
  2. On the Home tab, click the dropdown arrow next to the Borders button.
  3. Choose where the line goes — Bottom Border, Top Border, Left/Right Border, or run Draw Border to drag borders on by hand.
  4. For control over thickness, color, and dash style, open More Borders (or press Ctrl+1 / Cmd+1 and go to the Border tab).

Borders are the cleanest way to put a horizontal “line” under a header or a thick line above a sum. When you need to clear them again, see how to remove borders in Excel.

Format a line: weight, color, dashes, and arrowheads

Select any line shape and the Shape Format tab appears (called Shape Format in current versions; older versions label it Format). Click Shape Outline to control every aspect of the line:

  • Weight sets the thickness in points.
  • Color opens the palette, including custom colors.
  • Dashes switches between solid, dashed, and dotted styles.
  • Arrows adds or changes arrowheads on either end — turning a plain line into an arrow or a double-headed arrow without redrawing it.

For pixel-perfect control, right-click the line and choose Format Shape to open the side panel, where you can set exact endpoint and cap styles. Once one line looks right, you can copy its formatting to other lines fast with the Format Painter.

Move, lock, and delete a line

  • Move: click the line once to select it, then drag it, or nudge it with the arrow keys for fine adjustments.
  • Resize or re-angle: drag the round handles at either end.
  • Lock its position to the grid: by default a shape moves and resizes when the cells beneath it change. Right-click the line, choose Format Shape → Size & Properties → Properties, and pick Don’t move or size with cells. This is the fix for lines that jump around when you insert rows or change column widths.
  • Delete: select the line and press Delete (or Backspace on Mac).

Windows vs. Mac differences

The methods are the same across platforms, with a few label and key differences:

  • Shapes location is identical — Insert → Shapes — on both Windows and Mac.
  • Constrain key: Shift works on both. The gridline-snap modifier is Alt on Windows and Cmd on Mac.
  • Format tab name: Windows and Mac both call it Shape Format in Microsoft 365; older Mac builds may show Shape Format while older Windows builds say Format.
  • Draw tab: available on both, but most useful on touch devices (Surface, iPad-paired setups). On Mac it appears when you have a compatible trackpad or touch input.
  • Format Shape shortcut: Ctrl+1 on Windows, Cmd+1 on Mac.

Troubleshooting

My line won’t stay straight. You are not holding Shift. Press and hold Shift before you release the mouse button, not after — Shift snaps the angle only while you are dragging.

The line moves or stretches when I change cells. The shape is set to move and size with cells. Right-click it, choose Format Shape → Size & Properties → Properties, and select Don’t move or size with cells.

I can’t select the line / nothing happens when I click it. Either the line is behind another object (use Home → Find & Select → Selection Pane to pick it from the list and bring it forward), or the worksheet is protected (Review → Unprotect Sheet), or you clicked just off the thin line — zoom in and click directly on it.

The “line” I drew prints but isn’t on the grid. You drew a shape, which floats above cells. If you actually wanted a line tied to the cells, delete the shape and use a cell border instead.

Frequently Asked Questions

How do I draw a line in Excel?

Go to Insert → Illustrations → Shapes, click the straight line under the Lines heading, then click and drag on the worksheet. Hold Shift while dragging to keep the line perfectly straight. This works the same on Windows and Mac.

How do I draw a perfectly straight or horizontal line in Excel?

Hold the Shift key down while you drag the line. Shift constrains the line to the nearest 15-degree angle, so it snaps cleanly to horizontal, vertical, or diagonal. Release the mouse button before releasing Shift.

How do I insert a line in an Excel cell?

For a line that lives in a cell rather than floating on top of it, use a cell border. Select the cell, then on the Home tab click the Borders dropdown and choose a top, bottom, or full border. This is the right approach for underlines and dividers because the line moves with the cell.

How do I add a line under text or under a row of totals?

Select the cells, open the Borders dropdown on the Home tab, and choose Bottom Border (or Top Border for a line above a sum). For a heavier rule, open More Borders and pick a thicker line style before applying it.

How do I draw a line that connects two shapes?

Use a connector from the second row of the Lines gallery in Insert → Shapes. Hover over the first shape until connection points appear, click one, then drag to a point on the second shape. The connector stays attached and re-routes automatically when you move either shape.

Why does my line move when I insert rows or resize columns?

By default a line shape is anchored to move and size with the cells beneath it. Right-click the line, choose Format Shape → Size & Properties → Properties, and select Don’t move or size with cells to lock it in place.

Related guides

How To

How to Draw in Excel

Learn how to draw in Excel with our step-by-step guide. Improve your data visualization skills and create professional charts and graphs easily.

May 21, 2023

View all How To guides →