How to compare two strings for similarity or highlight differences in Excel?
In some cases, you may only need to compare two adjacent cells of strings and mark their similarities or differences in Excel. This article provides two methods for you to achieve it.
Compare two strings with formula
Compare two strings for similarity or highlight differences with VBA code
Compare two strings with formula
As below screenshot shown, if you just want to know whether the compared strings are matched or not, you can apply the following formula.
1. Select a blank cell C2, enter formula =EXACT(A2, B2) into the Formula Bar, and then press the Enter key. See screenshot:
Note: In the formula, A2 and B2 are the cells containing the comparing strings.
2. Keep selecting the result cell, then drag the Fill Handle to the cells until getting all compared results.
The FALSE result means that the compared strings are different, and the TRUE result indicates the two compared strings are matched. See screenshot:

Unlock Excel Magic with Kutools AI
- Smart Execution: Perform cell operations, analyze data, and create charts—all driven by simple commands.
- Custom Formulas: Generate tailored formulas to streamline your workflows.
- VBA Coding: Write and implement VBA code effortlessly.
- Formula Interpretation: Understand complex formulas with ease.
- Text Translation: Break language barriers within your spreadsheets.
Compare two strings for similarity or highlight differences with VBA code
If you want to compare two strings and highlight the similarities or differences between them. The following VBA code can help you.
1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module. Then copy and paste the following code into the Code window.
VBA code: Compare two column strings for similarity or highlight differences
3. Press the F5 key to run the code. In the first Kutools for Excel dialog box, select the first column of text strings you need to compare, and then click the OK button.
4. Then the second Kutools for Excel dialog box pops up, please select the second column strings, and click the OK button.
5. In the last Kutools for Excel dialog box, if you want to compare strings for similarity, click the Yes button. And to highlight the differences of the compared strings, click the No button. See screenshot:
Then you can see the compared results as below screenshot shown.
Related articles:
- How to compare two columns and highlight the unmatched data in Excel?
- How to exactly compare two strings (case sensitive) in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!