@Steven P you hit the nail on the head with your second response I knew that was the issue just didn't know how to verbalise it so thanks.
both your first and second bits of code works perfectly, although like you I prefer the second option its so much neater.
in the below you mention the +1 on the listindex. I'm confused with this, when I run the parts individually in AutoCAD both of the layerlist1 and listindex end up at the same number (23) so why start with +1 on the list index?
This second option looks so much neater.
Am I write in my understanding that you don't need to set the variables before the while loop because the loop will start at the first listindex number, set those variables, and then loop through.
This is all so I know for future reference ( I prefer to learn and understand rather than just take and use the code).
Thanks.