I got myself confused. I thought that E10 should display 5654 since it was different from 1239. However, since that isn't the case it seems that the second (array entered) formula* in post #8 is all that is needed.
- Select cell E2,
- paste the second formula from post #8 into the formula bar,
- *simultaneously press Ctrl,Shift and Enter.
You may then double click the fill handle to copy the formula down, and copy to the right as far as needed.
Let us know if you have any questions.