Hi Sam

thank you again for your answer. At the moment I would avoid to move inner loop into a new function.

Can you show me how to pass the variable outiside the loop and sent it to function result?

PS: sorry but I'm novice and it's faster for me to compare your correction. It will be nice if you can simply correct my code.