PDA

View Full Version : How to compare text in 2 cells and highlight incorrect text



mettu
03-21-2014, 03:33 AM
Ina sheet,i have to compare text in A with cell B and at the end highlight the text which is not same.please help.

ashleyuk1984
03-21-2014, 08:22 AM
You could do this with conditional formatting.

mettu
03-21-2014, 09:46 AM
I need to compare text in 2 different cells and highlight particular text or word which is incorrect using VBA.
For ex:- cell A has "This is for testing" and cell B has "This is for tes ting".
tes and ting need to be highlighted as they are not same as text in cell A.
I have to do this using VBA.
Please let me know your suggestions or code.

D_Marcel
03-21-2014, 10:30 AM
Mettu, welcome to VBAX!

Is the values in the column A always in the same position in the column B?



TEXT A
TEXT B


Germany
Germany


Italy
Ital y


Sweden
S we den




Well, if you only had to highlight the entire cell mismatched, would be easy, but separate the characters mismatched within the string it's not that simple. At least I'm not sure if there is an easy way.


Considering that the values is displayed as above, perhaps you can use a loop to read each row, extracting each character of the string in cell A and B, insert them into a dinamic arrays and them compare these two arrays. To each character mismatched, you do something, put it into another cell, another sheet...

Try to research about dinamic arrays and see if it can help you somehow.

Douglas