Cellwise Start free

Excel guide · 5 min read

How to find the longest streak in Excel

Quick answerAdd a helper column that counts up while the condition holds and resets to 0 when it breaks: =IF(B3="Yes",C2+1,0), filled down. =MAX(C2:C15) is the longest streak and the last value is the current one. Without a helper column, =MAX(FREQUENCY(IF(B2:B15="Yes",ROW(B2:B15)),IF(B2:B15<>"Yes",ROW(B2:B15)))) does it in one cell.

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

ABCD
1DateStudied?StreakDay streak
2Oct 19, 2026Yes11
3Oct 20, 2026Yes22
4Oct 21, 2026No00
5Oct 22, 2026Yes11
6Oct 23, 2026Yes22
7Oct 24, 2026Yes33
8Oct 26, 2026Yes41
9Oct 27, 2026No00
10Oct 28, 2026Yes11
11Oct 29, 2026yes22
12Oct 30, 2026Yes 03
13Oct 31, 2026Yes14
14Nov 1, 2026Yes25
15Nov 2, 2026Yes36

Download this sheet as an Excel practice file (.xlsx)

The helper column: count up, reset on a break

Say you're tracking a study habit, a run of days hitting a sales target, or a team's winning run. The sheet below logs each day with Yes or No in column B. The question is simple: what's the best streak so far, and where am I now?

Start the helper in C2 with =IF(B2="Yes",1,0). In C3, =IF(B3="Yes",C2+1,0) adds one to the cell above while the answer is Yes and drops to 0 on a No. Fill it down. Column C now reads 1, 2, 0, 1, 2, 3, 4, 0 and so on, and the biggest number is the longest streak.

This works in every Excel version, it's easy to check by eye, and it gives you the streak on every row, which is great for a chart. The = comparison ignores case, so the lowercase "yes" on 29 October still counts.

=MAX(C2:C15)

Result: 4

4: the run of Yes from 22 to 26 October is the longest the helper column can see.

The hidden space that breaks a streak

Look at 30 October: the cell says "Yes " with a space at the end, often left behind by a form or a copy from another app. To Excel that's a different word. =B12="Yes" returns FALSE and =LEN(B12) returns 4, so the helper resets to 0 and a six-day run shows up as 2 and 3.

COUNTIF has the same blind spot: =COUNTIF(B2:B15,"Yes") returns 11, while =SUMPRODUCT(--(TRIM(B2:B15)="Yes")) returns 12. Wrap the cell in TRIM inside the helper, =IF(TRIM(B3)="Yes",C2+1,0), or clean the column once (remove-spaces-in-excel shows how). A drop-down list for column B stops it happening again.

=B12="Yes"

Result: FALSE

FALSE: "Yes " with a trailing space is not "Yes", so the streak resets on 30 October.

One formula, no helper column: FREQUENCY

When you only want the number, FREQUENCY can do it in one cell. IF(B2:B15="Yes",ROW(B2:B15)) lists the row numbers of the Yes days, and IF(B2:B15<>"Yes",ROW(B2:B15)) lists the rows that break a streak. FREQUENCY counts how many Yes rows fall before each break, which is exactly the length of each run: here {2,4,2,3}. MAX picks the longest.

With TRIM around both B2:B15 references, the stray space stops mattering and the result becomes 6, the true run from 28 October to 2 November. In Excel 2019 and earlier, confirm the formula with Ctrl+Shift+Enter; in Excel 365 a normal Enter works.

To find the longest run of No instead (a losing streak, or days missed), swap "Yes" for "No" in both places. Here it returns 1. Excel 365 users can also build the running count inside one formula with SCAN and LAMBDA, but FREQUENCY works in every version.

=MAX(FREQUENCY(IF(TRIM(B2:B15)="Yes",ROW(B2:B15)),IF(TRIM(B2:B15)<>"Yes",ROW(B2:B15))))

Result: 6

6: the longest streak once the trailing space is trimmed away.

When did the streak start and end?

The end date is the date on the row where the helper hits its maximum: =INDEX(A2:A15,MATCH(MAX(C2:C15),C2:C15,0)) returns Monday 26 October. If two streaks tie, MATCH returns the first; =COUNTIF(C2:C15,MAX(C2:C15)) tells you whether there is a tie (here 1, so no).

For the start date, step back by rows, not by days. =INDEX(A2:A15,MATCH(MAX(C2:C15),C2:C15,0)-MAX(C2:C15)+1) returns Thursday 22 October. The tempting shortcut, end date minus 4 plus 1, gives Friday 23 October, which is wrong because Sunday 25 October has no row in the log.

=TEXT(INDEX(A2:A15,MATCH(MAX(C2:C15),C2:C15,0)-MAX(C2:C15)+1),"ddd d mmm")

Result: Thu 22 Oct

Thu 22 Oct: the first day of the 4-day streak, found by counting rows back from Mon 26 Oct.

The current streak

The current streak is just the helper's last value: C15 is 3. If the log keeps growing, point at the last filled row instead of a fixed cell: =LOOKUP(2,1/(A2:A100<>""),C2:C100) returns the helper value on the last row with a date, 3 today and whatever it is tomorrow.

Another common formula counts the rows after the last No: =ROWS(B2:B15)-XMATCH("No",B2:B15,0,-1) (Excel 365 and 2021). It returns 6 here, because it only looks for "No" and treats anything else, including "Yes " and blanks, as a Yes. Use it only when the column is clean.

=LOOKUP(2,1/(A2:A100<>""),C2:C100)

Result: 3

3: the streak running on the last logged day, 2 November.

Streaks of consecutive calendar days

A habit tracker often has gaps: no row means you didn't log that day. The rows for 24 and 26 October sit next to each other, but =A8-A7 returns 2, so a strict daily streak should break there. Add a date test to the helper: =IF(TRIM(B3)="Yes",IF(A3-A2=1,D2+1,1),0). A Yes after a gap starts again at 1.

Column D does exactly that. It restarts at 1 on 26 October and finds the longest true daily run, 28 October to 2 November. For work-day streaks that should skip weekends, swap A3-A2=1 for WORKDAY(A2,1)=A3: =WORKDAY(A7,1)=A8 is TRUE, because the next working day after Saturday 24 October is Monday 26 October.

=MAX(D2:D15)

Result: 6

6 consecutive days, ending Monday 2 November.

Common mistakes

Starting the helper with the C2+1 formula in row 2

Row 2 has no cell above it with a number (C1 is the header). Use =IF(B2="Yes",1,0) in the first row and the +1 formula from row 3 down.

Trailing spaces in the Yes/No column

"Yes " breaks the streak. Use TRIM in the test or clean the column and add a drop-down list.

Finding the start date with end date minus the streak length

That's only right when every day has a row. Count rows back with INDEX instead.

Ignoring gaps in the dates

A row-based streak treats missing days as if they never happened. Add an A3-A2=1 test when the streak must be consecutive calendar days.

FAQ

How do I count consecutive values in Excel?

Use a helper column: =IF(B3=B2,C2+1,1) counts how long the same value has repeated, or =IF(B3="Yes",C2+1,0) counts a run of one value. MAX of the column is the longest run.

How do I find the longest winning streak in Excel?

With W and L in column B, use =MAX(FREQUENCY(IF(B2:B50="W",ROW(B2:B50)),IF(B2:B50<>"W",ROW(B2:B50)))). Swap "W" for "L" to get the longest losing streak.

Can I find the longest streak without a helper column?

Yes, with the FREQUENCY formula above. It works in all versions; in Excel 2019 and earlier enter it with Ctrl+Shift+Enter.

How do I show the current streak in Excel?

Read the last value of the helper column, or use =LOOKUP(2,1/(A2:A100<>""),C2:C100) so it follows the list as it grows.

Functions used

Related guides

Updated