Counting longest spurt of consecutive cells with value
Hey y’all! In my data I have a row for every 6 hours for 12 months and a column with varying values for each row. Like,
A B
1/1/2026 0:00 -9.76
1/1/2026 6:00 -12.54
etc.
I need to count what was the longest length of time the values were above -12 for the entire year. Any ideas on how to do this?
I’m open to any solutions be it formulas, power query, or macros/VBA. I’m on 365 on a desktop. I’m currently cleaning up a bunch of data sheets other people made and this is a task we have to do frequently. In this workbook I’ll have to do it on 20+ columns and then do it again on each column for subsets of the time we have data for.
Their current solution is a C column with =IF(B2>=-12,C2+.25,0) to count the days >-12 in a row in 6 hour increments. Then in column D they have =IF(C3>C2+C4,C3,0) to have a column with just the max value of each consecutive spurt of time. At the end they run =MAX(D2:D1459) to get the longest spurt. Then they add 2 more columns for each subset of time they want to look at. It takes up half the workbook.
[link] [comments]
Want to read more?
Check out the full article on the original site