= index (SHEET 1! B:B, small (IF(SHEET 1! a$ 1:a$ 1000=a 1,row($ 1:$ 1000),4^8),row(a 1)))&; ""
The formula above is an array formula. After copying the formula, remember to press CTRL+SHIFT+ENTER to finish.
Pull-down filling
Just copy this formula to B 1 in other tables.