=ARRAYFORMULA(ARRAY_CONSTRAIN(QUERY({QUERY({Estimate!A2:H},
"where Col1 is not null"), IFERROR(VLOOKUP(QUERY({Estimate!A2:A},
"where Col1 is not null", 0),
IF(LEN(A5:A), {A5:A, ROW(A5:A)}, ), 2, 0))},
"where Col1 is not null
order by Col9", 0), 999^99, 8))