Wow! Not sure what else one can say really. That would have taken me literally weeks to come up with. It seems to be exactly what was required. I might even complete my PhD on time now ... Many thanks to all for useful and pertinent comments, and especially to JD for this function. Peter