Sub topic 9
Inserting, Resizing, Hiding, and Freezing Rows and Columns
This chapter covers how to change the structure of a sheet: adding and removing rows and columns, changing their size, hiding them, and keeping some of them visible while you scroll. It assumes you can select cells and ranges, enter values and formulas, and use undo. Everything here changes the grid, not the data inside the cells, but several of these actions affect formulas, so the edge cases matter.
Selecting whole rows and columns
Most structural actions start by selecting a row or column.
- Click a row number (left edge) or a column letter (top edge) to select the whole row or column.
- Drag across several headers, or click one header and Shift+click another, to select a block of adjacent ones.
- Ctrl+click (Cmd+click on Mac) headers to select non-adjacent rows or columns.
- Press Shift+Space to select the row of the active cell. Press Ctrl+Space (Cmd+Space on Mac) to select its column.
The number of rows or columns you select decides how many are inserted, deleted, hidden, or resized. Selecting three rows and inserting gives you three new rows.
Inserting rows and columns
Right-click a row number or column letter to open the context menu. For a row you will see Insert 1 row above and Insert 1 row below. For a column you will see Insert 1 column left and Insert 1 column right. If you selected several headers, the label changes to match, for example Insert 3 rows above.
You can also use the Insert menu at the top of the window. It offers the same options based on your current selection.
New rows and columns inherit the formatting of the row or column next to them, such as fonts, fills, and number formats. They do not inherit the values. If the inserted row looks wrong, use Format > Clear formatting (Ctrl+\\) on it.
Inserting cells instead of whole rows
If you select only part of a row, such as B3:D3, the right-click menu offers Insert cells with choices to shift cells right or down. This moves only the selected area. Use it carefully, because it can misalign data in the rest of the row, which then no longer matches the columns around it.
Deleting rows and columns
Right-click the header and choose Delete row or Delete column. Deleting removes the data and the grid position. Clearing is different. Pressing Delete with a row selected empties the cells but keeps the row in place.
Deleting has a side effect on formulas. If a formula refers to a cell in a deleted row, that reference becomes #REF!.
=B2*B3If you delete row 3, the formula becomes =B2*#REF! and shows an error. If you delete a row inside a range such as B2:B10, the range shrinks to B2:B9 and the formula keeps working.
How insertion affects formulas
When you insert a row or column, Sheets adjusts references so formulas keep pointing at the same data.
=SUM(B2:B10)- Insert a row above row 5 and the formula becomes
=SUM(B2:B11). - Insert a row directly below row 10 and the formula stays
=SUM(B2:B10). The new row is outside the range, so it is not included.
The second case is a common error. A total that sits just under the data will not grow when you add a row at the bottom edge. To avoid this, insert the new row between existing data rows, or write the range to include a spare row above the total.
flowchart TDThe diagram below summarizes where a new row falls relative to a range.
Resizing rows and columns
Drag the border between two headers to change the size of the row or column on its left or above it. Several actions are faster than dragging.
- Double-click the border to fit the size to the content. For a column, this fits the widest entry. For a row, it fits the tallest wrapped text.
- Select several headers and drag one border. All selected rows or columns take the same size.
- Right-click a header and choose Resize row or Resize column. The dialog lets you type an exact size in pixels, or choose Fit to data.
Resizing changes only the display. A number that does not fit in a narrow column shows as ### rather than being cut off or changed. Widen the column to see it again. Text is different. Long text overflows into empty neighboring cells, or is clipped if the neighbor holds data. Wrapping and overflow are covered in a later chapter.
Hiding and unhiding
Right-click a header and choose Hide row or Hide column. Hidden rows and columns are not deleted. Their data still exists and formulas still use it.
Sheets marks the place where something is hidden with small arrow icons on the headers on either side of the gap. Click an arrow to show the hidden rows or columns again.
Keep these points in mind:
- Hiding does not remove values from calculations.
SUMstill counts hidden cells. - Functions such as
SUBTOTALandAGGREGATEcan skip hidden rows when you choose the right function code.SUBTOTAL(109, B2:B10)sums while ignoring rows you hid manually. - Copying a range that includes hidden rows also copies the hidden data when you paste.
- A hidden row can hide a problem. If a total looks wrong, check for arrow icons on the headers.
=SUBTOTAL(109,B2:B10)Hiding versus filtering
Filters also make rows disappear, but the mechanism is different. A filter hides rows that do not match a condition and can be changed quickly. Manual hiding is a fixed choice that you control row by row. Use hiding for helper columns and notes. Use a filter when you want to show a changing subset of data.
Freezing rows and columns
When a sheet is longer or wider than the screen, headers scroll out of view. Freezing keeps chosen rows or columns in place while the rest scrolls.
Open View > Freeze. The options are:
| Option | Effect |
|---|---|
| No rows | Removes the row freeze |
| 1 row | Freezes the top row |
| 2 rows | Freezes the top two rows |
| Up to row N | Freezes every row down to the row of the active cell |
| No columns | Removes the column freeze |
| 1 column | Freezes column A |
| 2 columns | Freezes columns A and B |
| Up to column X | Freezes every column up to the column of the active cell |
You can also drag the thick gray bar in the top-left corner of the grid. Drag it down or right to the position you want.
Freezing always starts from the top or left edge. You cannot freeze a block of rows in the middle of the sheet. Rows and columns can be frozen together, for example the header row and an ID column.
Be careful with large freezes. Frozen areas always take screen space. If you freeze too many rows on a small screen or a zoomed-in browser, the frozen area can fill the window and leave no room to scroll. Sheets warns you in some cases, and you can fix it by setting View > Freeze > No rows.
Frozen panes also work with merged cells in a limited way. You cannot freeze a boundary that cuts through a merged cell, and Sheets shows an error. Unmerge the cells or choose a different boundary.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Total misses a new row | Row was inserted just below the range | Insert inside the range, or widen the range |
| `#REF!` in a formula | A row or column it referred to was deleted | Undo, or rewrite the reference |
| Numbers show `###` | Column is too narrow | Widen or autofit the column |
| Sum includes unseen values | Rows are hidden, but still counted | Unhide, or use `SUBTOTAL(109, ...)` |
| Cannot scroll the sheet | Too many rows frozen | Set freeze to No rows |
| Freeze fails with an error | Boundary crosses a merged cell | Unmerge or move the boundary |
Exercise
A sheet has =SUM(B2:B10) in cell B11. You right-click row 11 and choose Insert 1 row above, then type a new value in the new row 11. Is the new value included in the total? What would you do to make sure future rows are counted?
Show answer
No. The new row sits directly below the last row of the range, so the range stays B2:B10. To include it, insert new rows between existing data rows, such as above row 10, or edit the formula to cover the new row, such as =SUM(B2:B11). Leaving a blank spare row inside the range also works.
Exercise
You hide rows 5 to 7, and a column total still includes their values. Which formula would give the total of only the visible rows in B2:B10, and why does SUM not do this?
Show answer
=SUBTOTAL(109,B2:B10). SUM counts every cell in the range whether or not the row is hidden. Function code 109 in SUBTOTAL ignores rows that were hidden manually.