Highlight the Top Three Nonzero Values in Excel
Question details
Highlight the three largest nonzero numeric values in an Excel range or PivotTable.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user wants to compare values across multiple columns or independently within each column while excluding zeros.
- Observed behavior
- The desired formatting highlights the largest nonzero values and leaves an all-zero range unhighlighted.
Identify the range to compare and decide whether the top values should be calculated across the whole range or separately for each column. The examples below use B1:D5 and assume B1 is the top-left cell of the selection.
Highlight the top three nonzero values across a range
Use one formula-based rule to compare all numeric values in B1:D5, including negative values.
The formula counts nonzero values greater than each cell. Values with fewer than three larger nonzero values are highlighted. Ties can result in more than three highlighted cells.
In Excel, select B1:D5, starting with B1 as the active cell.
Go to Home > Conditional Formatting > New Rule. Select Use a formula to determine which cells to format.
Enter =AND(ISNUMBER(B1),B1<>0,COUNTIFS($B$1:$D$5,">"&B1,$B$1:$D$5,"<>0")<3). For another range, replace both absolute range references and change B1 to the selection's top-left cell.
Select Format, choose a fill or other style, and click OK. Click OK again to create the rule.
Go to Home > Conditional Formatting > Manage Rules and confirm that Applies to covers B1:D5.

Calculate the top three nonzero values in each column
Create a separate rule for each column when each column needs its own top-three comparison.
Highlight nonzero top values in WPS Spreadsheet
Use a formula-based conditional formatting rule in WPS Spreadsheet to compare nonzero values across your selected range.
- 1. Open your workbook: Open WPS Spreadsheet and select Open to choose your Excel workbook.
- 2. Select the values: Select B1:D5, or select your own range and note its top-left cell.
- 3. Create a rule: Go to Home > Conditional Formatting > New Rule and choose the formula-based rule option.
- 4. Enter the formula and format: Enter =AND(ISNUMBER(B1),B1<>0,COUNTIFS($B$1:$D$5,">"&B1,$B$1:$D$5,"<>0")<3), adjust the references if needed, and choose a fill color.
- 5. Apply and save: Confirm the rule, check the highlighted cells, and select Save.

Frequently Asked Questions
What happens if all the values are zero?
The B1<>0 condition prevents zero cells from being highlighted, so an all-zero range has no highlighted cells.
Why are more than three cells highlighted?
Values tied at the cutoff are all highlighted. The rule compares value ranks rather than selecting exactly three cells.
Can the rule highlight negative numbers?
Yes. The COUNTIFS formula excludes zeros but includes negative numeric values when they are among the largest nonzero values.
How do I apply the rule to a different range?
Select the new range, replace both $B$1:$D$5 references with that range, and replace B1 with its top-left cell. Check the Applies to range under Home > Conditional Formatting > Manage Rules.
Will the PivotTable rule expand after a refresh?
Excel may offer an All cells showing option for a PivotTable value field in Manage Rules. Select it when available, then check the formula's fixed comparison range after refreshing or changing the PivotTable.




