Formatting Issues

Highlight the Top Three Nonzero Values in Excel

Huda QurayshiHuda Qurayshi Nov 18, 2026 869 views

Question details

Highlight the three largest nonzero numeric values in an Excel range or PivotTable.

Highlight the Top Three Nonzero Values in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Select the range

In Excel, select B1:D5, starting with B1 as the active cell.

2
Create a formula rule

Go to Home > Conditional Formatting > New Rule. Select Use a formula to determine which cells to format.

3
Enter the formula

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.

4
Choose the format

Select Format, choose a fill or other style, and click OK. Click OK again to create the rule.

5
Check the rule

Go to Home > Conditional Formatting > Manage Rules and confirm that Applies to covers B1:D5.

Highlight the top three nonzero values across a range
Zeros and small ranges: If every value is zero, nothing is highlighted. If fewer than three nonzero numeric values exist, all of them are highlighted.
WPS Spreadsheet

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. 1. Open your workbook: Open WPS Spreadsheet and select Open to choose your Excel workbook.
  2. 2. Select the values: Select B1:D5, or select your own range and note its top-left cell.
  3. 3. Create a rule: Go to Home > Conditional Formatting > New Rule and choose the formula-based rule option.
  4. 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. 5. Apply and save: Confirm the rule, check the highlighted cells, and select Save.
Highlight the largest nonzero values across multiple columnsOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interfaceWork with spreadsheet files using the free version of WPS Office
microsoft office alternative - wps office

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.