Number of Same Value Appear in a Range of Time

ibmy

Board Regular
Joined
Mar 4, 2020
Messages
106
Office Version
  1. 2016
Platform
  1. Windows
Dear Smartest Excelers,

Need help on formula in D3 or micro.
A sample from 90k row data :

Time Group.xlsx
ABCDE
1timevalue10 seconds
200:05:4290.777
300:08:4290.111
400:08:4690.1111
500:10:1493.333
600:12:2590.001
700:12:2590.0011> count , same second and in 10 seconds range before
800:17:5592.212
900:18:0192.2121
1000:18:1190.112
1100:27:1489.987
1222:53:4289.987> no count, same value but not in 10 seconds range before
1322:53:5389.987> no count, same value but not in 10 seconds range before
1422:54:5191.207
1522:58:3790.01
1623:39:3994.004
1723:39:4293.333> no count, time is in range of 10 seconds but not same value before
1823:39:4494.001
1923:40:2091.111
2023:40:4291.111> no count, same value but not in 10 seconds range before
2123:40:5091.1111
2223:40:5391.1112
2323:41:0291.1113
2423:43:5591.111> no count, same value but not in 10 seconds range before
2523:43:2789.999
26
Sheet2


Rule: The value must be the same from previous row (Column C) & Time in 10 seconds range from previous row (Column B)

Hopefully, the formula/micro also can be modified to desire custom range : 1 minute (60seconds), 1 minute 30 seconds (90seconds),etc...
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi, maybe you can give this a try.

Book1
BCD
1timevalue10 seconds
200:05:4290.777
300:08:4290.111 
400:08:4690.1111
500:10:1493.333 
600:12:2590.001 
700:12:2590.0011
800:17:5592.212 
900:18:0192.2121
1000:18:1190.112 
1100:27:1489.987 
1222:53:4289.987 
1322:53:5389.987 
1422:54:5191.207 
1522:58:3790.01 
1623:39:3994.004 
1723:39:4293.333 
1823:39:4494.001 
1923:40:2091.111 
2023:40:4291.111 
2123:40:5091.1111
2223:40:5391.1112
2323:41:0291.1113
2423:43:5591.111 
2523:43:2789.999 
Sheet1
Cell Formulas
RangeFormula
D3:D25D3=IF(AND(C3=C2,B3-B2<TIME(0,0,10)),N(D2)+1,"")
 
Upvote 0
Solution
Use Criteria as seconds at cell G1:
TestFormatting.xlsm
ABCDEFG
1timevalue10 SecondsCriteria(Seconds)10
20:05:4290.777 
30:08:4290.111 
40:08:4690.1111
50:10:1493.333 
60:12:2590.001 
70:12:2590.0011
80:17:5592.212 
90:18:0192.2121
100:18:1190.112 
110:27:1489.987 
1222:53:4289.987 
1322:53:5389.987 
1422:54:5191.207 
1522:58:3790.01 
1623:39:3994.004 
1723:39:4293.333 
1823:39:4494.001 
1923:40:2091.111 
2023:40:4291.111 
2123:40:5091.1111
2223:40:5391.1112
2323:41:0291.1113
2423:43:5591.111 
2523:43:2789.999 
Sheet4
Cell Formulas
RangeFormula
D1D1= 10 & " Seconds"
D2:D25D2=IF(IFERROR(IF(AND(C2=C1,(B2-B1)<$G$1/86400),COUNTIFS($C$2:C2,C2,$B$2:B2,">="&B2-$G$1/86400)-1,""),"")="","",IFERROR(IF(AND(C2=C1,(B2-B1)<$G$1/86400),COUNTIFS($C$2:C2,C2,$B$2:B2,">="&B2-$G$1/86400)-1,""),"")+IF(D1="",0,D1))
 
Upvote 0
=COUNTIFS($C$2:$C$21,C2,$B$2:$B$21,">="&B2-0.00694444444444444,$B$2:$B$21,"<="&B2)-1
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top