Hi,
It would be very hard (or impossible?) to achieve this by macro, since macro step works on one planning object of certain level each time. It does not have interaction with other planning objects and other planning levels.
You can use fixing functionality, that is, fix the total row. With this, if a detailed row is changed, other detailed rows will be adjusted to keep the total value unchanged.
BR, Ada