Sub topic 14
Copying visible cells only in filtered or hidden ranges
This chapter assumes you can select ranges, copy and paste, and apply a basic filter. It also assumes you have used Go To Special to select cells. Here you will learn when Excel copies hidden cells along with visible ones, and how to stop it.
Why hidden cells get copied
Rows and columns can be hidden in two ways:
- A filter hides rows that do not match its criteria.
- You can hide rows or columns yourself by right-clicking and choosing Hide.
Excel treats the two cases differently when you copy:
| Situation | What a normal copy does |
|---|---|
| Rows hidden by a filter | Copies only the visible rows |
| Rows or columns hidden manually | Copies the hidden cells too |
| Collapsed outline groups | Copies the hidden cells too |
The manual case surprises people. You select A1:D20 with rows 5 to 9 hidden, paste elsewhere, and the hidden rows come along. They may appear in the pasted result, and your report then contains data you meant to leave out.
Copy only the visible cells
Use Visible cells only to tell Excel to skip hidden cells. It is a selection mode, so you apply it before you copy.
- Select the range, for example A1:D20.
- Press Alt+; (Windows). On a Mac, press Cmd+Shift+Z. Alternatively, choose Home > Find & Select > Go To Special > Visible cells only > OK.
- Copy with Ctrl+C. The marching border now surrounds only the visible blocks.
- Click the top-left cell of the destination and paste with Ctrl+V.
Selected range: A1:D20 (rows 5-9 hidden by hand)
After Alt+; only rows 1-4 and 10-20 are selected
Copy and paste to F1 pastes 15 rows, with no hidden dataThe pasted rows are contiguous. The gap left by the hidden rows closes up in the destination.
Pasting into a filtered range
The reverse problem also exists. Pasting a block of several rows over a filtered list does not reliably skip the hidden rows. You can overwrite data you cannot see.
Safer habits:
- Paste into an empty area or a new sheet.
- Clear the filter before pasting over a list.
- After pasting, remove the filter and check that the hidden rows are unchanged.
Checking your result
Compare counts before and after. Select the filtered column and read the Count in the status bar. It counts only visible cells. Then select the pasted column and compare the two numbers. If the pasted count is larger, hidden cells were copied.
Common mistakes
- Pressing Alt+; after you have already copied. The selection mode must come first.
- Assuming a filter and a manual hide behave the same. They do not.
- Forgetting that formulas in the copied cells still follow the reference rules from earlier chapters. Copying visible cells does not change how relative references shift.
Exercise
Rows 3 to 6 of A1:C10 were hidden by right-clicking Hide, not by a filter. You copy A1:C10 and paste it at E1. What do you find in E1:G10, and what should you have done first?
Show answer
The hidden rows 3 to 6 are pasted too, because a normal copy includes manually hidden rows. You should have selected A1:C10, pressed Alt+; (Cmd+Shift+Z on Mac) to select Visible cells only, and then copied and pasted.
Exercise
You filter a list so 12 rows show, then copy and paste the filtered column. The status bar count of the pasted column is 40. What does this tell you?
Show answer
Hidden cells were copied. Only the 12 visible cells should come over, so something other than a plain filtered copy happened. For example, the range may have included manually hidden rows, or the filter was cleared before the copy. Re-apply the filter, select Visible cells only, and copy again.