That sounds fairly specific. I think you'll have to write that one.
The DMU workbench has the means to do what you ask manually. You could probably record the manual steps and then modify them to make a more general macro. Any scripting to do what you seek would be using the DMU workbench functions.