Thanks, it works on sample data.
Btw, I've question about this part.
AGGREGATE(15,6,(COLUMN(Sheet2!$A$1:$C$1)-COLUMN(Sheet2!$A$1)+1)/(Sheet2!$A$2:$C$10=A2),1)
What is the meaning of 1 in AGGREGATE function?
The AGGREGATE function can apply different aggregate functions to a list or database with the option to ignore hidden rows and error values.
support.microsoft.com
Based on link above, I know that:
AGGREGATE(function_num, options, array, [k])
15 is a function_num for function "SMALL"
6 is an Option to "Ignore error values"
(COLUMN(Sheet2!$A$1:$C$1)-COLUMN(Sheet2!$A$1)+1)/(Sheet2!$A$2:$C$10=A2)
is the "array"
and
1 is for [k].
What is the meaning of "1 is for [k]"?