The real trick is to develope DonkeyOtes' formulae to cover all eventualities.

I'm not a whizz-kid with formulae, so I posted a step-by-step procedure.

Developing Dons' solution would give you a "live" solution that would update as you changed the values in your grid, something my solution fails to do.