VBA Compare two strings, highlight differences

cgmojoco

Well-known Member
Joined
Jan 15, 2005
Messages
699
Hi there-

Example---how can I get the red highlighting to work like so?

<table x:str="" style="border-collapse: collapse; width: 187px; height: 90px;" border="0" cellpadding="0" cellspacing="0"><col style="width: 42pt;" span="2" width="56"> <tbody><tr style="height: 11.25pt;" height="15"> <td style="height: 11.25pt; width: 42pt;" width="56" height="15">Test</td> <td style="width: 42pt;" width="56">Test_002</td> </tr> <tr style="height: 11.25pt;" height="15"> <td class="xl22" style="background: silver none repeat scroll 0% 0%; height: 11.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" height="15">6698F</td> <td class="xl23" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">ES6698F</td> </tr> <tr style="height: 11.25pt;" height="15"> <td class="xl22" style="height: 11.25pt;" height="15">DVP3142</td> <td class="xl22">DVP3144</td> </tr> <tr style="height: 11.25pt;" height="15"> <td class="xl22" style="background: silver none repeat scroll 0% 0%; height: 11.25pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" height="15">GTM8800</td> <td class="xl22" style="background: silver none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">GTI8000</td> </tr> <tr style="height: 11.25pt;" height="15"> <td class="xl22" style="height: 11.25pt;" height="15">SDV394</td> <td class="xl22">SV384STC</td> </tr> </tbody></table>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Ok I just wanted to verify that, I will see what I can compe up with, but basically you are saying anything in Test_002 that is not in Test should be highlighted?

You have in Test:

6689F

Then say you have Test_002:

123456789

Or is this not really a possible outcome?

Actually the last one I am not quite understanding bevause it seems you want the letters in the same place but a D is missing in the last one and the V is not colored?

This is not very clear on the logic at least to me.
 
Upvote 0
Yes with the added functionality of if it does exist but is in the wrong order...

I.e.

ABC vs. CAB should still highlight...

Of course this makes it infinitely complex I'm sure...
 
Upvote 0
if you have AB123 vs. ABB12523 what do you want highlighted?

In such cases, would highlighting the whole cell be the desired outcome?
 
Upvote 0
I probably edited my post after you read some of it, but this does not seem to be a simple task as the logic seems to have many solutions, based on one's knowledge?
 
Upvote 0
if you have AB123 vs. ABB12523 what do you want highlighted?

In such cases, would highlighting the whole cell be the desired outcome?

Great question and I should apologize for not describing this in more detail in my original message.

AB123 vs. ABB12523
 
Upvote 0
Thanks for asking about that detail.

I'll go ahead and run this against column A as well, so it will highlight 1 in column a.
 
Upvote 0

Forum statistics

Threads
1,215,352
Messages
6,124,457
Members
449,161
Latest member
NHOJ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top