Function Problems

Count Repeated Code Occurrences in Excel with COUNTIF

Adam DavisAdam Davis Nov 12, 2026 868 views

Question details

Count the number of occurrences of every code in a column and display each code's count in a second column.

Count Repeated Code Occurrences in Excel with COUNTIF
Product
Microsoft Excel
Device & OS
not provided
Scenario
A large code list contains duplicate values, and the user needs a formula that returns the total frequency for each row's code.
Observed behavior
Each code should receive a count showing how many times that same value appears in the full code range.
Before you start

Confirm that the code values are in one continuous column and that the count column is empty. Adjust the example range A2:A200 to include the first and last cells in your actual list.

Solution 1Recommended

Use COUNTIF and fill the formula down the count column

Use this reliable method when each row needs a count for its corresponding code, regardless of how many unique codes are in the list.

The COUNTIF criteria range is locked with dollar signs so it remains unchanged as the formula is copied down. The criteria cell, A2, changes to match each row's code.

1
Enter the COUNTIF formula

In the first count cell, such as B2, enter =COUNTIF($A$2:$A$200,A2), where A2:A200 is the full code list.

2
Confirm the result

Press Enter to show the number of times the code in A2 appears in A2:A200.

3
Copy the formula to remaining rows

Select B2, then drag the fill handle at the lower-right corner of the cell down through the last row next to your codes.

Use COUNTIF and fill the formula down the count column
Works with large lists: COUNTIF does not require a separate formula for each unique value. The same formula can be filled down for hundreds or thousands of codes.
Count duplicate codes efficiently

Count Repeated Codes in WPS Spreadsheets with COUNTIF

WPS Spreadsheets lets you count repeated codes with the familiar COUNTIF function. Enter one formula beside your code list, then fill it down to calculate the frequency of every value in a large column.

  1. 1. Open the worksheet in WPS Spreadsheets: Open your Excel workbook in WPS Office and select the worksheet containing the code column.
  2. 2. Add the COUNTIF formula: Click the first cell in the count column, such as B2, and enter =COUNTIF($A$2:$A$200,A2).
  3. 3. Calculate the first count: Press Enter to count the occurrences of the code in A2 across the full range.
  4. 4. Fill the formula down: Select B2 and drag its fill handle down to the last row beside the code list.
Use COUNTIF to count every repeated code in a selected range.Fill formulas down quickly with the cell fill handle.Open and edit Microsoft Excel .xlsx and .xls files with compatible formulas.Work in a lightweight spreadsheet interface with familiar Excel-style tools.
microsoft office alternative - wps office

Frequently Asked Questions

How do I count each duplicate code in Excel?

In the first result cell, enter =COUNTIF($A$2:$A$200,A2), then copy or drag the formula down. Replace A2:A200 with the complete range containing your codes.

Why are dollar signs used in the COUNTIF range?

The dollar signs lock the range. When you fill the formula down, $A$2:$A$200 stays fixed while the criteria reference changes from A2 to A3, A4, and so on.

Does COUNTIF work when there are more than 100 unique values?

Yes. COUNTIF counts matches in the specified range and is not limited by the number of unique values. Use a range that includes all rows of your list.

Can I use a named range instead of cell references in COUNTIF?

Yes. After naming the code list CodeRange through Formulas > Define Name, use =COUNTIF(CodeRange,A2) and fill the formula down.

How can I count duplicates in WPS Spreadsheets?

In WPS Spreadsheets, click the first output cell and enter =COUNTIF($A$2:$A$200,A2). Press Enter, then drag the fill handle down to apply the formula to the rest of the rows.