Homework, eh? Tsk, tsk.
Okay, I'm sending you the example.
I'll probably still whip up a VBA example tomorrow, because it's an interesting problem.
But don't hand that in if your prof knows anything about VBA, it's probably going to be obvious that you didn't write it.