I need a formula to return the smallest unique value that meets a specific criteria, to the Nth term. Please look at image:

[![Example Layout](https://i.stack.imgur.com/GHm3R.jpg)](https://i.stack.imgur.com/GHm3R.jpg)

Goal is to have a formula in cells D2:G31 that will return the values of B2:B31 in order of smallest to largest that contain the value in D1:G1.

For example cell D2 would return 3 because it is the smallest value in the "1's" group. Cell D3 would return 12, Cell E2 would return 1, Etc...

I have tried using the code below but it just returns TRUE, I am not sure how to achieve my goal, but maybe this will help your understanding.

```
=AND(VLOOKUP(1,A2:B31,2),SMALL(B2:B31,1))

```