Function Problems

How to Group Excel Rows by Matching Item Numbers and Filter Results

John WilsonJohn Wilson Nov 3, 2026 870 views

Question details

The user needs a method to group spreadsheet rows by matching item numbers and delete the entire group if at least one row within it contains a 'Pass' result.

How to Group Excel Rows by Matching Item Numbers and Filter Results
Product
Excel
Device & OS
not provided
Scenario
Filtering out groups of duplicate item numbers based on a specific condition occurring in any one of the related rows.
Observed behavior
The user requires a solution to delete all associated duplicate rows when at least one matching row meets the exclusion criteria.
Before you start

Ensure your data has clear column headers, and confirm which specific columns contain the item numbers and the target status (e.g., 'Pass').

Solution 1Recommended

Use Sorting and a COUNTIFS Helper Formula

This method uses a helper column to flag entire groups based on a condition, allowing you to easily filter and delete the unwanted rows.

By combining the standard sorting feature with a COUNTIFS formula, you can count how many times a 'Pass' status appears for a specific item number. If the count is greater than zero, it means the group contains at least one passing result, and the formula will return TRUE for the entire group.

1
Sort the Data

Select your entire data range, navigate to the Data tab, click Sort, and sort the data by the Item Number column to group matching rows together visually.

2
Add a Helper Formula

In a new adjacent column (e.g., Row 2), enter the formula =COUNTIFS($B:$B,B2,$C:$C,"Pass")>0. Adjust column B to your Item Number column and column C to your Status column.

3
Filter the Results

Select the header row, go to the Data tab, and click Filter. Click the filter dropdown on your new helper column and check only the 'TRUE' box.

4
Delete Filtered Rows

Select all the visible rows containing TRUE, right-click the row numbers on the far left, and choose 'Delete Row'. Clear the filter to view the remaining valid groups.

Use Sorting and a COUNTIFS Helper Formula
Tip: Using absolute references (like $B:$B) ensures the formula checks the entire column accurately when dragged down to other rows.
Free Spreadsheet Software

Group and Filter Data Easily with WPS Spreadsheet

WPS Spreadsheet fully supports advanced functions like COUNTIFS and FILTER, allowing you to seamlessly manage, group, and clean up duplicate data entries. It provides a familiar interface to handle large datasets effortlessly.

  1. 1. Open Your File: Launch WPS Spreadsheet and open your dataset containing the item numbers.
  2. 2. Apply Helper Column: Create a new column and insert the COUNTIFS formula to flag groups containing the target value.
  3. 3. Use AutoFilter: Go to the Data tab, click AutoFilter, and filter the helper column by your specified criteria.
  4. 4. Delete Rows: Highlight the filtered rows, right-click the row numbers, and select Delete to remove the entire matched groups.
Fully compatible with Microsoft Excel (.xlsx, .xls) filesComprehensive support for logical formulas, including COUNTIFS and arraysLightweight, fast, and free to use for daily data analysis
microsoft office alternative - wps office

Frequently Asked Questions

Why is my COUNTIFS formula returning 0 for all rows?

This usually happens if the column references in the formula do not match where your data actually sits. Ensure that your references (like $B:$B and $C:$C) precisely target the columns containing your item numbers and pass/fail statuses.

Can I use conditional formatting to highlight these groups instead of deleting them?

Yes. You can select your entire data range, go to Conditional Formatting under the Home tab, choose 'New Rule', select 'Use a formula to determine which cells to format', and input the same COUNTIFS formula (e.g., =COUNTIFS($B:$B,$B2,$C:$C,"Pass")>0) to highlight the groups.

Will deleting filtered rows delete the hidden rows as well?

No, as long as you select the visible rows and right-click on the row numbers on the left side to delete them, Excel will only remove the rows that are currently filtered and visible. The hidden rows will remain intact when you clear the filter.