Dear mr edstein,
Thank you very much for your reply. I am a noob when it comes to visual basic coding. I have copied the above code from some other post and have tweaked it a bit. To be honest I am not hundred percent sure I understand what you meant with your reply. I have no idea how to use option explicit command. I would greatly appreciate if you could help me solve this issue. I have also attached the zip file for your reference.
Again, thank you very much for your help mr edstein.