Just a script method is fine. Does not need to be a UDF.

Want to see if the user knows how to do it.

I agree with Gargoyle that it might be nice to at least briefly explain what your code is doing or what you "think" your code is doing so that if needed it can be critiqued.

I'm in no way wanting to slam anyone for their code or explanation. Just want to help others to get better at scripting overall.