I don't have a lot of confidence when I code with arrays or collections, because I'm not good with it. It's a lot of trial and error, so I'm always relieved when I find a solution by myself (which does not happen everytime) that works halfway. This was the case, but of course your solution is a great improvement, because now it works far better than only halfway. ;-)
I have a second version of the tool selecting by shape type, and it was easy to adapt your array solution to that one.

Again: Thank you very much!