Assuming the formula I posted doesn't do what you want, I think you need to post a workbook and explain in context.