Ok, I assume you mean the items in column A that correspond to the non-blank
rows in Valx. Redefine the named range table to include column A:
Name: Table
Refers to: =$A$2:$D$7
Change the formula in I1 to:
=COUNTA(INDEX(Table,,MATCH(H1,A1
1,0)))
Change this expression in the formula in F1 (in 2 places):
From:
MATCH(H$1,B$1
$1,0)
To:
MATCH(H$1,A$1
$1,0)
Make sure you re-enter as an array!
And finally, enter this array formula in E1 and copy down:
=IF(ROWS(E$1:E1)<=I$1,INDEX(Table,SMALL(IF(INDEX(Table,,MATCH(H$1,A$1
$1,0))<>"",ROW(Table)),ROWS(E$1:E1))-MIN(ROW(Table))+1,1),"")