Hi Alan, I found some test data.
I found a ready written IMS macro to sort my test data (which was a real bonus). And I got your code sample to run and get the right answer. Thank you - I owe you a virtual beer. To all the other correspondents - thank you - a simple request has generated some extremely lively discussion (from some of the usual suspects). Dougie
