Did the formula I posted above solve your problem? If not, what exactly is causing it to fail?

If you can create an example workbook that has data to test our logic with then we can help, otherwise I struggle to understand what exactly you are trying to do.
Ideally we would want to see adequate sample data, AND a hard-coded number (or numbers) to see what you are trying to do, and for us to prove our formula works as you want.


If you have any questions let me know I am glad to help.