How to Filter Two Rows in Excel: Step-by-Step
In this article
To filter two rows in Excel, you need to use the filter feature on a range that includes both rows as data, not as headers. Excel's standard filter treats the first row of your selection as column headers, so if you want to filter on two specific rows, you must first restructure your data or use a helper column. The quickest method is to add a helper column that flags the two rows you want, then filter on that column. Alternatively, you can use Advanced Filter with a criteria range that references the two rows, or simply select the two rows and use a filter by selection if you only need to hide others temporarily. Below is a step-by-step guide for the most reliable approach using a helper column, followed by alternatives and troubleshooting.
What You'll Need
- Microsoft Excel (any recent version for Windows or Mac; steps may differ slightly in Excel for the web or older versions).
- A dataset with at least two rows you want to filter on, and ideally a header row.
- Basic familiarity with selecting cells and using the ribbon or menu bar.
Step-by-Step
- Open your workbook and locate the worksheet containing the data. Ensure your data is organized in columns with a single header row at the top. If your data has no headers, you can still filter, but Excel will treat the first row as headers by default—so it's best to add a header row first.
- Insert a helper column to the right of your data (or in any empty column). In the first cell of that column (e.g., cell F2 if your data ends at column E), type a formula that identifies the two rows you want. For example, if you want to filter rows where the value in column A is "Apple" or "Banana", you could use:
=IF(OR(A2="Apple",A2="Banana"),"Keep","Hide"). Press Enter and copy the formula down to all rows. This creates a flag for the rows you want to keep. - Select your entire data range, including the helper column and the header row. You can click any cell in the range and press Ctrl+A (Windows) or Command+A (Mac) to select the current region, or drag to select manually.
- Turn on the filter by going to the Data tab on the ribbon and clicking the Filter button (it looks like a funnel). Drop-down arrows will appear in each header cell. In Excel for Mac, the Filter button is also on the Data tab. In Excel for the web, it's under Data > Filter.
- Click the drop-down arrow in the helper column header. In the filter menu, uncheck "Select All" and then check only "Keep". Click OK. Excel will now hide all rows where the helper column says "Hide", leaving only the two rows (or more, if your criteria match multiple rows) visible.
- Verify the result. You should see only the rows that meet your criteria. The other rows are hidden, not deleted. You can copy, edit, or print the visible rows as needed.
- To remove the filter, click the Filter button again on the Data tab, or clear the filter from the helper column drop-down by checking "Select All". You can also delete the helper column if no longer needed.
Alternative method: Advanced Filter — If you prefer not to add a helper column, you can use Advanced Filter. Set up a criteria range somewhere on your sheet with the same header as your data column and list the two values you want to filter on in the rows below. Then go to Data > Advanced, choose "Filter the list, in-place", set the List range to your data, and the Criteria range to your criteria cells. Click OK. This will filter the rows matching either criterion. Note that Advanced Filter can be finicky with exact match and wildcards; test on a copy first.
Alternative method: Filter by selection — If you only need to temporarily hide all rows except two specific rows, you can select those two rows (click the row numbers on the left while holding Ctrl or Command), then right-click and choose Hide. This hides the rows but is not a true filter; it's manual and not dynamic. To unhide, select the rows around the hidden ones and right-click > Unhide.
Common Mistakes
- Including the header row in the filter range incorrectly — If you select only the two data rows and click Filter, Excel may treat the first of those rows as a header, causing your filter to behave unexpectedly. Always include the actual header row in your selection.
- Forgetting to copy the helper formula down — If you only put the formula in the first row, the filter won't work for other rows. Drag the fill handle or double-click it to copy down.
- Using the wrong column in the filter drop-down — Make sure you filter on the helper column, not on a data column that might have similar values.
- Assuming hidden rows are deleted — Filtering hides rows; it does not remove them. If you copy visible cells and paste elsewhere, Excel may include hidden rows unless you use "Visible cells only" (Alt+; on Windows).
- Not accounting for blank cells — If your helper formula returns blank for some rows, those rows may be filtered out unexpectedly. Use an IFERROR or ensure the formula always returns a value.
Tips
- Use a descriptive header for your helper column, like "FilterFlag", so you remember its purpose.
- Instead of hardcoding values in the formula, you can reference cells where you type your criteria. For example, put "Apple" in H1 and "Banana" in H2, then use
=IF(OR(A2=$H$1,A2=$H$2),"Keep","Hide"). This makes it easy to change the filter without editing the formula. - If you need to filter on two rows that are not adjacent, the helper column method handles that perfectly—just list both criteria.
- To quickly select all visible cells after filtering, press Alt+; (Windows) or Command+Shift+Z (Mac, though the shortcut may vary). This helps when copying filtered results.
- Consider converting your data to an Excel Table (Ctrl+T) before filtering. Tables automatically expand formulas and make filtering more intuitive.
Troubleshooting
- Filter drop-downs don't appear — Make sure you have a single header row and no merged cells in the header. If your data is in a table, the filter arrows appear automatically. Also check that you're on the Data tab and the Filter button is highlighted.
- Only one row shows up instead of two — Check your helper formula: it might be case-sensitive or have a typo. Ensure the criteria match exactly, including spaces. Use TRIM to remove extra spaces if needed.
- Filter menu shows blanks or errors — This can happen if the helper column contains error values. Wrap your formula in IFERROR to return "Hide" for errors.
- Cannot see the filter arrows because the header is scrolled off — Freeze the top row (View > Freeze Panes > Freeze Top Row) so headers stay visible.
- Advanced Filter returns no results — Ensure the criteria range headers exactly match the data headers (same spelling, same case not required but spacing matters). Also check that the criteria values are entered in the correct rows (one value per row under the header).
- Filtered rows still appear when printing — By default, Excel prints hidden rows unless you set the print area to visible cells only. Go to Page Layout > Print Titles and check "Print hidden rows" is off, or select visible cells and set print area.
Frequently Asked Questions
Can I filter two rows without adding a helper column?
Yes, you can use Advanced Filter with a criteria range that lists the two rows' criteria, or you can manually hide rows. However, the helper column method is the most straightforward and dynamic.
How do I filter rows based on two different columns?
You can use the standard filter drop-downs on each column to set criteria, but to filter two specific rows (i.e., row 2 and row 5), you need a helper column that flags those rows, or you can use Advanced Filter with multiple criteria rows.
Why does Excel treat my first data row as a header?
Excel's filter assumes the first row of your selection contains column headers. If you select only data rows, the first row becomes the header. Always include your actual header row in the selection.
Can I filter two non-adjacent rows?
Yes, the helper column method works for any rows. Just set the formula to flag the specific rows you want, regardless of their position.
What happens to the hidden rows when I copy and paste?
By default, Excel copies hidden rows as well. To copy only visible rows, select the range, press Alt+; (Windows) or use Go To Special > Visible cells only, then copy.
Is there a limit to how many rows I can filter?
No, you can filter any number of rows; the helper column can flag as many as you need. The filter will show all rows that meet the criteria.