My question is same as marshajr1 and I think its totally relevant to the topic. I had to sort columns A and G replaced B with G in above code but it didn't worked.