Highlight Values That Appear Exactly Three Times in an Excel Row
Question details
Highlight values that occur exactly three times across each row in an Excel range.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user wants to compare values across multiple columns in each row using conditional formatting.
- Observed behavior
- Values appearing exactly three times in a row should be highlighted; values appearing fewer or more times should remain unhighlighted.
Identify the columns and rows to check, and note the top-left cell of the selected range. The example below uses A1:G100, with each row counted independently.
Create a COUNTIF Conditional Formatting Rule in Excel
Use a formula to highlight each nonblank value that appears exactly three times within its row.
In the worksheet, select A1:G100, or select your own target range starting from its top-left cell.
Go to Home > Conditional Formatting > New Rule, then choose Use a formula to determine which cells to format.
Enter =AND(A1<>"",COUNTIF($A1:$G1,A1)=3). This counts matching values across columns A through G in the current row and excludes blank cells.
Click Format, open the Fill tab, choose a color, and click OK. Click OK again to create the rule.
Go to Home > Conditional Formatting > Manage Rules and confirm that Applies to covers the intended cells, such as =$A$1:$G$100.

Highlight Values Appearing Three Times in WPS Spreadsheets
Use a formula-based conditional formatting rule in WPS Spreadsheets to highlight values that occur exactly three times across each row.
- 1. Open the spreadsheet: Open WPS Spreadsheets and use Open to select your workbook.
- 2. Select the cells: Select the range to check, such as A1:G100.
- 3. Add a formatting rule: Go to Home > Conditional Formatting > New Rule and choose the option to use a formula to determine which cells to format.
- 4. Set the formula and format: Enter =AND(A1<>"",COUNTIF($A1:$G1,A1)=3), choose a fill color under Format, and confirm the rule. Adjust the references if your selected range differs.

Frequently Asked Questions
Will the rule highlight values that appear twice?
No. The =3 condition highlights a value only when COUNTIF finds exactly three occurrences in the row.
Does the formula count matches across the entire worksheet?
No. COUNTIF($A1:$G1,A1) checks columns A through G in the current row. Adjust the column references to match the range you want to compare.
Why does the formula include A1<>""?
That condition prevents blank cells from being highlighted when exactly three cells in the row are empty.
How do I change the range covered by the rule?
In Excel, go to Home > Conditional Formatting > Manage Rules and edit Applies to. If the columns or starting row change, also edit the formula to match the new range and its top-left cell.




