Hi Tony. Thanks for your reply! I think it looks like that might be very similar, if not the same, as what I am trying to do. Let me play around with it for a while (it will probably take me a little bit of time to get my head round the individual elements of the formula!) and I will get back to you and let you know if it works.