You are welcome Chippi and thanks for the reputation point.
Please don't forget to mark the thread as solved.
=IFERROR(B2-INDEX(B:B,SMALL(IF((C$2:C$13=IF(LEFT(C2,1)="I","T","I")&MID(C2,2,255))*(ABS(B$2:B$13-B2)<--"0:00:10"),ROW(C$2:C$13)),1)),"")
Start from here :
IF(LEFT(C2,1)="I","T","I") --> this will find the pair alphabet, so if "I" then yield "T", and if "T" then yield "I"
then :
IF(LEFT(C2,1)="I","T","I")&MID(C2,2,255) --> this will add remaining number or the pairs, I2 will be T2, T3 will be I3 etc
Now use array formula to find matched candidates :
For example, lets take row 3, the value of cell C3 is I1, so the previous formula will yield T1
To find the matched candidates :
(C$2:C$13="T1")*(ABS(B$2:B$13-B3)<--"0:00:10")
this will return array with 12 items (12 = number of items in C2:C13) with value either True of False according whether it fullfills the two conditions.
First condition is check whether current cell = T1
Second condition is check whether difference time between current cell with any other cells in range B2:B13 is less than 10 seconds
Using multiply operation between first and second condition means both conditions must be True to yield True
The array operation is :
[?is? C2 = "T1" ] = False * [?is? ABS(B2 - B3) < 10 seconds] = True
[?is? C3 = "T1" ] = False * [?is? ABS(B3 - B3) < 10 seconds] = True
[?is? C4 = "T1" ] = False * [?is? ABS(B4 - B3) < 10 seconds] = True
[?is? C5 = "T1" ] = True * [?is? ABS(B5 - B3) < 10 seconds] = True
[?is? C6 = "T1" ] = False * [?is? ABS(B6 - B3) < 10 seconds] = False
[?is? C7 = "T1" ] = False * [?is? ABS(B7 - B3) < 10 seconds] = False
[?is? C8 = "T1" ] = False * [?is? ABS(B8 - B3) < 10 seconds] = False
[?is? C9 = "T1" ] = False * [?is? ABS(B9 - B3) < 10 seconds] = False
[?is? C10 = "T1" ] = False * [?is? ABS(B10 - B3) < 10 seconds] = False
[?is? C11 = "T1" ] = False * [?is? ABS(B11 - B3) < 10 seconds] = False
[?is? C12 = "T1" ] = False * [?is? ABS(B12 - B3) < 10 seconds] = False
[?is? C13 = "T1" ] = False * [?is? ABS(B13 - B3) < 10 seconds] = False
which result is :
False (= False * True)
False (= False * True)
False (= False * True)
True (= True * True)
False (= False * False)
False (= False * False)
False (= False * False)
False (= False * False)
False (= False * False)
False (= False * False)
False (= False * False)
False (= False * False)
Now using if() formula to change the member who has true value into row number where this array's member located ("False" members are not changed) :
IF(the_array_above, ROW(C$2:C$13))
will yield :
False
False
False
5 --> because the condition is true, the row number C5 which is 5 returned
False
False
False
False
False
False
False
False
Then we get the first item from the array using :
SMALL(above_array,1)
which will yield 5
And then we get the cell B5, using :
INDEX(B:B, SMALL(...))
INDEX(B:B, 5)
The different time between B3 and B5 is :
B3-INDEX(B:B, 5)
B3-B5
And to prevent error value showed up, we use :
IFERROR(B3-B5,"")
If you don't understand it yet, please don't be upset, array formula is hard to learn, you can googling and start learning from simpler examples and advancing to master it.
Regards
Bookmarks