I have a workbook with two worksheets

Sheet1 column C contains a list of names
Sheet1 column D contains a list of alphanumberic values

I have the below formula in another worksheet which is reading in a value from cell B3, looking this up in Sheet1 column D and returning the value from Sheet1 column C. I want to return all returned values across the row, eg. cell E3, E4, E5, etc. This works fine in the first cell containing the formula. I then copied it across horizontally and get a !NUM error in all the other cells.

=INDEX(Sheet1!$C$2:$C$5000, SMALL(IF($B$3=Sheet1!$D$2:$D$5000, ROW(Sheet1!$D$2:$D$5000)-MIN(ROW(Sheet1!$D$2:$D$5000))+1, ""), COLUMN(B1)))

Can somebody please tell me where I'm going wrong?

Thanks,