Easy to do it manually, but can it be done proramatically?

Just to complete this thread… The similar solution was found here.