=INDEX(Sheet1!$1:$1048576, 12, 2):INDEX(Sheet1!$1:$1048576, CodesCount, 2)

I'm not sure in what way that would be considered dynamic if CodesCount is a constant ...