Q:

Retrive row number of MIN IF formula

I would like to know the row being used in a MIN(IF()) formula so I can use it to grab a another value in the same row..
I have this formula:
Between the two sheets
A is an Id 
B is a Date
C is another Id on Sheet2
{=MIN(IF(Sheet2!A:A=A1,B1-Sheet2!B:B,""))}
I want to know which row in Sheet2!B:B is being used to calculate the formula, then return the value in Sheet2 column C for that row. 
Maybe I could use INDEX or MATCH if I only knew the row number being used in the calculation! 
A different formula may have to be used to achieve this, but I wanted to demonstrate what I have so far.   It is calculating correctly.   I just need it to grab the Id in Sheet2 column C now...

A:

First of all, it's not at all a good idea to use entire column references within an array formula (or indeed any other non-CSE array-processing function, such as SUMPRODUCT, AGGREGATE, etc.). 
Unlike some functions, e.g. COUNTIF(S), SUMIF(S), with which the use of entire column references has virtually no detriment to calculation performance, array-processing functions must calculate over all cells passed to them.  And that applies equally to those cells which are beyond the last non-empty cell in the range being passed. 
So if, for example, you only have data extending as far as row 1000, then, by using entire column references in such a formula, you are forcing Excel to calculate more than one million cells beyond that which is actually necessary, an astonishing amount for a single formula. 
As such, it is important to either choose a suitably low - though sufficient - value for the upper row reference, or else make your ranges dynamic, such that the upper row reference is determined via a function which automatically detects the last-used cell within the column, thus offering maximum efficiency. 
As to your problem, you can use the following array formula:
=INDEX(Sheet2!C:C,MATCH(MIN(IF(Sheet2!A1:A100=A1,B1-Sheet2!B1:B100)),IF(Sheet2!A1:A100=A1,B1-Sheet2!B1:B100),0))
Note that I choose an upper row reference of 100 here, which obviously you can amend, though bearing in mind the points I raised earlier.  If you like, I can also show you how to set up the dynamic ranges to which I alluded. 
Also note the repetition of the conditional statement within MATCH's lookup_array, a crucial point which is missed an astonishing number of times in proposed solutions to this kind of problem, the error being to use simply:
=INDEX(Sheet2!C:C,MATCH(MIN(IF(Sheet2!A1:A100=A1,B1-Sheet2!B1:B100)),B1-Sheet2!B1:B100,0))
which, although it may work, does not at all guarantee correct results, by virtue of it being logically flawed. 
Regards

