Yep - I'm a regular blue meanie arn't I - but hey you get what you pay for... All I was trying to do was avoid the usual 20+ questions before we get to the actual issue.
That said, I've taken a look at your code and you don't need to say any more. I'm afraid it's just a complete non-sensical mess and IMHO not worth spending any time on (yours or mine).
My advice FWIW would be start afresh by writing a SHORT piece of code for each thing you need to happen. So for example write a piece of code that just rotates the carousel. Then when you're happy write the code to rotate it to a particular slot. Then write the code to (say) open/close the solenoid etc. etc. ALL as separate macros so you can go back to them if needs be. Then you'll have all the aspects of your toolchanger under your hat. Then put them together ONE AT A TIME checking each new step behaves as you want. Then you'll not only have your toolchanger but YOU'LL undertand it. Follow someone elses code ONLY for simple techniques (if you need to) like how to close/open a solenoid and even then check a few peoples code to convince yourself you're not following someone else's rubbish.
PLEASE DO NOT FOLLOW any of the code you've posted - there's just about NOTHING in there as it stands that is either correct OR good technique.
Come back whenever you need help - I'll try to be Mr. Nice if you try to not make me guess what your problem is if that's fair enough.
Ian