Welcome to the forum!

It is unclear what you are asking. Maybe you could make an even shorter example. I can't see the logic in what you did to solve the equation. You seem to have left some out.

Once we understand the logic, a vba solution can be designed.