I'm sure whatever it it could be implemented in VBA, but I can't visualize what you're looking for.

Maya a small, complete example (20 lines or so) with inputs and desired output?