Thank you very much. The code worked perfectly well.
But I have one last issue. There are two sets of values 'A' and 'B'. The code you gave me is considering B set values only.
Is there any way I can ask it to look for A first and then move to B.
Thank you again. It was very helpful.