I see that you are using parts of my code and that is a good thing! That code had some limitations although it worked for your originally posted problem. I posted some more code at
based upon your new requirement input in that thread. I guess you where posting here while I was in the process of writing more code. Have a look and use what you want.