Hi Marc L, Thanks for your response. But I am getting a runtime error 1004 (Attachment 846267). However the code given by Jindon is working very fine. Thank you.