thanks guy

Ive tested out the UDF you mentioned.

when I run it I get the message
Error: array reference out of bounds!
Line : 217