that sounds quite complicated. The only way I could think of helping you with this is to create a new list next to where each code is. In this list each code will be included only once and there you will have to choose the warehouse for each code. If a code is not marked it will not be assigned.