thanks charles for your reply but after running your code i get totaly wrong result if you see my attched file result sheet then you will get what result should be there.(kindly compare my result sheet data with your result data)