ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. Running Count in Excel: Number Each Occurrence With COUNTIF

Running Count in Excel: Number Each Occurrence With COUNTIF

By ExcelReady Team·Updated November 3, 2026·6 min read

The short answer

A running count numbers each occurrence of a value as it appears down a list: the first Lena is 1, the second Lena is 2. In Excel, type =COUNTIF($B$2:B2,B2) in the first row and fill it down. The locked start ($B$2) and moving end (B2) make a range that grows by one row each time.

Key takeaways

  • =COUNTIF($B$2:B2,B2) counts how many times the current value has appeared so far, including this row.
  • Lock only the start of the range. $B$2:B2 grows as you fill down; $B$2:$B$8 would give the total count instead.
  • A running count of 1 marks the first occurrence, and anything above 1 is a repeat.
  • Join the value and its count, such as Lena-2, to make unique IDs for lookups.
  • Use COUNTIFS with two expanding ranges for a running count with more than one condition.
On this page+
  1. What is a running count?
  2. How to make a running count with COUNTIF
  3. Why the dollar signs matter
  4. Flag duplicates and first occurrences
  5. Build unique IDs and find the nth match
  6. Running count with more than one condition
  7. Running counts in tables and long lists
  8. Practise it

A running count in Excel numbers each occurrence of a value as you go down a list: the first time "Lena" appears she gets 1, the second time 2, the third time 3. One COUNTIF formula with a growing range does it, and it is the base for flagging duplicates, building unique IDs and finding the second or third match. This guide shows the formula, why the dollar signs matter, and the most useful ways to put a running count to work.

What is a running count?#

A running count is a count that updates row by row. Each row asks "how many times have I seen this value so far, including now?". The examples use this order list in A1:C8:

ABCD
1OrderCustomerStatusRunning count
21001LenaPaid1
31002OmarPaid1
41003LenaOpen2
51004RaviPaid1
61005OmarPaid2
71006LenaPaid3
81007RaviOpen2

Column D is the running count. Lena's third order, in row 7, shows 3. Don't confuse it with a running total, which adds up numbers row by row instead of counting values.

How to make a running count with COUNTIF#

Type this in D2 and fill it down to D8 (Windows: Ctrl+D; Mac: ⌘D):

Excel formula
=COUNTIF($B$2:B2,B2)

COUNTIF counts the cells in a range that match a value. The trick is the range, $B$2:B2:

  • $B$2 is locked with dollar signs, so the start always stays on row 2.
  • B2 has no dollar signs, so the end moves down as you fill.

In D7 the formula has become =COUNTIF($B$2:B7,B7). It counts "Lena" in B2:B7 and finds her in rows 2, 4 and 7, so it returns 3. This kind of range is called an expanding range. The COUNTIF function guide covers the syntax, and the COUNTIF article shows other criteria.

Why the dollar signs matter#

The formula only works with the start locked and the end free. Compare what row 7 shows with each version:

Formula in D2Becomes in D7Result in D7What it counts
=COUNTIF($B$2:B2,B2)=COUNTIF($B$2:B7,B7)3Lenas so far (correct)
=COUNTIF(B2:B2,B2)=COUNTIF(B7:B7,B7)1Only the current row
=COUNTIF($B$2:$B$8,B2)=COUNTIF($B$2:$B$8,B7)3All Lenas, on every Lena row

The last version looks right in row 7 but shows 3 for every Lena row, including the first. That's a total count, not a running count. Press F4 on Windows or ⌘T on a Mac to cycle through the dollar sign options. The dollar sign guide to absolute references explains mixed references like this one in more detail.

Flag duplicates and first occurrences#

A running count of 1 means "first time seen", and anything higher is a repeat. Label the rows with IF:

Excel formula
=IF(COUNTIF($B$2:B2,B2)>1,"Repeat","First")

Rows 4, 6, 7 and 8 show Repeat. To count how many different customers there are, count the 1s in the running count column:

Excel formula
=COUNTIF(D2:D8,1)

The result is 3: Lena, Omar and Ravi. Filter column D to 1 to see a list of first orders only. To colour the repeats instead of labelling them, select B2:B8, choose Home > Conditional Formatting > New Rule > Use a formula, and enter =COUNTIF($B$2:B2,B2)>1. Every second and later occurrence is highlighted. For other ways to find and count repeated values, see how to count duplicates in Excel.

Build unique IDs and find the nth match#

Join the value and its running count to make a key that is unique on every row. In E2:

Excel formula
=B2&"-"&COUNTIF($B$2:B2,B2)

Row 2 shows Lena-1, row 4 Lena-2 and row 7 Lena-3. Now a normal lookup can find any occurrence, not just the first. To get the order number of Lena's second order:

Excel formula
=XLOOKUP("Lena-2",E2:E8,A2:A8)

The result is 1003. XLOOKUP needs Excel 2021 or Microsoft 365; in older versions use =INDEX(A2:A8,MATCH("Lena-2",E2:E8,0)), which returns the same order.

Running count with more than one condition#

COUNTIFS accepts several range and criteria pairs, and each range can expand. To number only each customer's paid orders:

Excel formula
=IF(C2="Paid",COUNTIFS($B$2:B2,B2,$C$2:C2,"Paid"),"")

Lena's paid orders get 1 and 2 (rows 2 and 7), and her open order in row 4 stays blank. Both ranges must start on the same row and grow together, otherwise COUNTIFS returns #VALUE!.

For a plain row number that skips blank rows, use an expanding COUNTA: =IF(B2="","",COUNTA($B$2:B2)). The guide to auto-numbering rows covers that and other numbering methods.

Running counts in tables and long lists#

In an Excel table (Insert > Table), an expanding range such as $B$2:B2 can be adjusted inconsistently when new rows are added. This version always starts at the first row of the column:

Excel formula
=COUNTIF(INDEX([Customer],1):[@Customer],[@Customer])

INDEX([Customer],1) is the first cell of the Customer column and [@Customer] is the current row, so the range still grows by one row each time.

A running count depends on row order. If you sort the list by date or by customer, the numbers recalculate for the new order, so Lena's "first" order may change. When you need numbers that stay fixed, such as IDs you have already sent to someone, copy the column and paste it back as values (Windows: Ctrl+Alt+V; Mac: ⌃⌘V, then choose Values).

Each row's COUNTIF checks every row above it, so the work grows quickly with the length of the list. A few thousand rows is fine; on hundreds of thousands, a pivot table or Power Query is faster.

Practise it#

Try the exercise on this page: one COUNTIF with a half-locked range numbers Lena's third order. Then practise COUNTIF in a live spreadsheet and practise relative and absolute references, where you'll fill formulas down and see exactly which parts move.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Number each customer's orders. Click D7 and count how many times the customer in B7 appears from B2 down to row 7, with the start of the range locked. Press Enter.

fx
ABCDE
1
Order
Customer
Status
Running count
2
1001
Lena
Paid
3
1002
Omar
Paid
4
1003
Lena
Open
5
1004
Ravi
Paid
6
1005
Omar
Paid
7
1006
Lena
Paid
8
1007
Ravi
Open
9
10
11

Tip: The range starts at a locked $B$2 and ends at B7 on this row. The criteria is B7 itself.

Practise this in a lesson

LessonCOUNTIFCount the cells that match a condition, from exact words to number checks like ">=8".LessonRelative vs absolute references ($)Lock a cell with $ so it doesn't move when you copy a formula, one of the most-tested Excel skills.Function guideCOUNTIFCount cells that match one condition with COUNTIF: text, numbers, wildcards and cell references. Real examples and a live exercise.

Frequently asked questions

How do I number duplicates in Excel?

+

Use a running count: =COUNTIF($B$2:B2,B2) in the first row, filled down. The first time a value appears it shows 1, the second time 2, and so on.

Why does my running count show the same number on every row?

+

The range is fully locked, as in $B$2:$B$8, so every row counts the whole column. Lock only the start: $B$2:B2. If every row shows 1, the start isn't locked at all.

How do I find the first occurrence of each value?

+

Rows where the running count equals 1 are first occurrences. Use =IF(COUNTIF($B$2:B2,B2)=1,"First","Repeat") to label them, or filter the running count column to 1.

Does a running count work in an Excel table?

+

Yes, but a formula like $B$2:B2 can be adjusted oddly when the table grows. A safer version is =COUNTIF(INDEX([Customer],1):[@Customer],[@Customer]), which always starts from the first row of the column.

Sources

  • COUNTIF function - Microsoft Support
  • COUNTIFS function - Microsoft Support
  • Switch between relative, absolute, and mixed references - Microsoft Support

Written and checked by the ExcelReady Team. First published November 3, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What is a running count?
  2. How to make a running count with COUNTIF
  3. Why the dollar signs matter
  4. Flag duplicates and first occurrences
  5. Build unique IDs and find the nth match
  6. Running count with more than one condition
  7. Running counts in tables and long lists
  8. Practise it

Keep reading

Conditional math· 6 min read

How to Use COUNTIF in Excel (With Criteria Examples)

COUNTIF counts the cells in a range that meet one condition. Write =COUNTIF(range, criteria), for example =COUNTIF(D2:D9,"Open") to count open tickets. Put text and comparisons in double quotes, like ">=8" or "<>Low". Numbers and cell references go in without quotes. For two or more conditions, use COUNTIFS.

Conditional math· 6 min read

How to Count Duplicates in Excel

To count duplicates in Excel, use COUNTIF. =COUNTIF($A$2:$A$8,A2) shows how many times the value in A2 appears; any result above 1 is a duplicate. To count every row that is part of a duplicate set in one cell, use =SUMPRODUCT(--(COUNTIF(A2:A8,A2:A8)>1)). Decide first whether you need repeated rows, extra copies or repeated values.

Math· 6 min read

Absolute References and the $ Sign in Excel

An Excel absolute reference uses dollar signs, like $F$1, to lock a cell so it doesn't change when you copy or fill a formula. Use it for a value every row shares, such as a tax rate: =B2*(1+$F$1). Press F4 while editing to add the $ signs. $F1 locks only the column; F$1 locks only the row.

More on conditional math

  • How to Sum by Category in Excel
  • Sum by Date Range or Month in Excel With SUMIFS
  • How to Sum by Month in Excel With SUMIFS
  • How to Sum by Quarter in Excel
  • How to Sum by Week in Excel
  • How to Sum by Year in Excel
All conditional math articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free