I think VBA would be easier for this. Does each ID always only show up once?