My apologies. As Mr. Shorty pointed out, there were two lines missing from my code. I have modified the file and inserted the missing statements. I have attached this macro enabled file which includes the corrected macro and a short subroutine called TestUDF that can be called from the developer tab to run the macro.
Bookmarks