Google Formula

Take a look at this thread. It’s something I tried that seemed to work. It involves turning on iterative calculations in the sheet. Maybe this would work for you with some modification to the formula.