thanks for quick help
let me try to give more clarification
Column A column B
Line1 12345 i love
Line2 12345 i love india
Line3 12345 i love india and indians.
Line4 12344 i love london
Line5 12399 i love usa
Line6 12399 i love usa and people of usa.
Line7 12399 i love usa and people of uk
line number 3 is the lowest level of line
line number 4 has no lower level so it should return
line number 6 and 7 is the lowest level of line number 5
yes u are right that line no 2 is lower level of 1 but it is not lowest as line number 3 is present below it and i required lowest levels.
my logic is first macro should look the code number in column A if they are same then it should go to see the text weather it is part of next cell in column B if yes then it should move to next cell and return the lowest level.(line number 3 in above example)
if code number is not the same then there is no need to check text it should return the same text from column B.(Line number 4 in above example)
also if the code is same and text is not part of immediate cell in column B then it should return both current text in column B and immediate next cell text in column B.(line number 6 and 7 in above example)
i hope it will be more celar.
please tell if i can give some more clarification.