Sub topic 14
Copying visible cells only in filtered or hidden ranges
This chapter assumes you can select ranges, copy and paste, apply a basic filter, and hide rows or columns from the ribbon or right-click menu. It builds on Go To Special and on copying cells. Here you will learn when Excel copies hidden cells, when it skips them, and how to force the behavior you want.
Why hidden cells cause trouble
Rows and columns can be out of sight for three reasons: a filter removed them, you hid them by hand, or they sit inside a collapsed outline group. Excel treats these cases differently when you copy.
The rules are:
- Filtered rows are skipped when you copy a selected range and paste it. Excel copies only the rows that remain visible.
- Rows or columns hidden by hand are copied along with everything else in the selection. The pasted block shows data you did not expect.
- Grouped (collapsed) rows behave like manually hidden rows, so they are copied too.
The difference between the first rule and the other two is the source of most mistakes. The same copy command gives different results depending on how the cells were hidden.
A worked example
Suppose a sales sheet holds these data in A1:C7.
| Row | A: Region | B: Rep | C: Sales |
|---|---|---|---|
| 1 | Region | Rep | Sales |
| 2 | East | Ana | 1200 |
| 3 | West | Ben | 800 |
| 4 | East | Cho | 950 |
| 5 | West | Dev | 700 |
| 6 | East | Eli | 1100 |
| 7 | West | Fay | 600 |
You want a separate list of East sales only.
Case 1: copying filtered rows
- Select A1:C7 and choose Data > Filter.
- Open the filter arrow on Region and keep only East. Rows 3, 5, and 7 disappear.
- Select A1:C7, then press Ctrl+C. A marching border appears around the visible rows only.
- Click a cell on another sheet, such as E1, and press Ctrl+V.
The pasted block contains the header and the three East rows. You did not need any extra step, because Excel skips filtered-out rows automatically.
Case 2: copying manually hidden rows
Now remove the filter. Select rows 3, 5, and 7, right-click, and choose Hide. The sheet looks the same as before, but the rows are hidden by hand.
If you select A1:C7, copy, and paste at E1, all seven rows appear in the pasted block. The hidden rows come along with the rest.
To copy only what you can see:
- Select A1:C7.
- Press F5 (or Ctrl+G), click Special, choose Visible cells only, and click OK. You can also press Alt+; (semicolon) as a shortcut on Windows.
- Press Ctrl+C. The marching border now outlines separate visible blocks.
- Click E1 and press Ctrl+V.
The result has four rows: the header and the three East rows.
Adding the command to the toolbar
If you do this often, add Select Visible Cells to the Quick Access Toolbar.
- Right-click the Quick Access Toolbar and choose Customize Quick Access Toolbar.
- In the Choose commands from list, pick All Commands.
- Select Select Visible Cells and click Add.
- Click OK.
The command now sits one click away, and it gets an Alt+number shortcut based on its position on the toolbar.
Hidden columns and other layouts
The same logic applies to columns. Filters act on rows only, so hidden columns are always hidden by hand or by grouping. A normal copy includes them. Select the range, use Visible cells only, and then copy.
Be careful when your selection mixes hidden rows and hidden columns. Visible cells only removes both. The pasted result is a compact block of the cells that were visible in both directions.
What gets pasted, and where
When you paste visible cells, Excel places them in contiguous cells. The gaps left by hidden rows do not carry over. The destination is fully packed.
Pay attention to the destination as well:
- If the destination range is itself filtered, Excel pastes into every cell in the range, including hidden ones, in some cases. The values may land in rows you cannot see. The safest approach is to paste into an unfiltered area, such as another sheet.
- If you paste over existing data, Excel overwrites it without asking. Choose an empty area first.
- Pasting formulas keeps their references adjusted by the usual relative and absolute rules, so check them after pasting.
Deleting and editing visible cells only
The same selection trick helps with other commands:
- Delete the contents of the visible cells only. Select the range, use Visible cells only, and press Delete. Hidden cells keep their data.
- Apply formatting such as a fill color. Without the visible-only selection, formatting reaches hidden rows too, so it appears later when you unhide them.
- Delete rows. If you filter first and then select the visible rows and use Delete Row, Excel deletes only the visible filtered rows. This is a standard way to remove all records that match a condition. Clear the filter afterwards to confirm what remains.
Deleting is hard to reverse once you save and close the file. Use Ctrl+Z at once if the result looks wrong, and keep a backup copy for large clean-ups.
Totals and formulas that ignore hidden rows
Copying is only one side of the problem. If you sum a column by formula, a hidden row is still counted by SUM. Two functions help.
=SUBTOTAL(109, C2:C7)
=AGGREGATE(9, 5, C2:C7)SUBTOTAL with function number 109 sums the range and ignores rows hidden by hand. Function number 9 ignores filtered rows only. Rows hidden by a filter are ignored by both. AGGREGATE with function 9 (sum) and option 5 ignores hidden rows as well.
Use these when you want the total to match what you see on screen, then copy the visible values with the steps above if you need a static list.
Common mistakes and recovery
| Mistake | What happens | How to fix it |
|---|---|---|
| Copying manually hidden rows with a normal copy | Hidden data appears in the pasted result | Undo, select the range, use **Visible cells only**, copy again |
| Pasting into a filtered list | Values land in hidden rows | Undo, clear the filter or paste to another sheet |
| Selecting a whole column and using **Visible cells only** on a huge sheet | The selection is slow and large | Select just the used range first |
| Forgetting to clear a filter | Later work affects only part of the data | Use **Data > Clear** to show all rows |
| Using `SUM` on a filtered list | The total includes hidden rows | Switch to `SUBTOTAL` or `AGGREGATE` |
Checking your result
After pasting, compare the row count of the source and the destination. A quick check is the status bar at the bottom of the window. With a filter on, it shows "N of M records found". Selecting the pasted column shows a count of the selected cells. If the numbers differ from what you expect, undo and repeat the steps.
Exercise
A range A1:C7 has rows 3, 5, and 7 hidden by hand, with no filter. You select A1:C7, press Ctrl+C, and paste at E1. How many rows appear, and what do you do to paste only the four visible rows?
Show answer
Seven rows appear, because a normal copy includes manually hidden rows. Undo the paste, select A1:C7, press F5 or Ctrl+G, click Special, choose Visible cells only, and click OK. Then copy and paste at E1. The result has four rows.
Exercise
Why does =SUM(C2:C7) still show the full total after you filter a list to East only, and which formula matches what you see?
Show answer
SUM counts every cell in the range, including rows hidden by the filter. =SUBTOTAL(109, C2:C7) adds only the visible cells, so it matches the filtered view.