Skip to main content

Conditional formatting rows or cells if two columns equal in Excel

Author: Sun Last Modified: 2020-11-20

In this article, I introduce the method on conditional formatting rows or cells if two columns equal in Excel.

Method A Conditional formatting rows or cells if two columns equal  Method B Highlight and select cells if two columns equal 
doc conditional formatting if equal 1 doc conditional formatting if equal 2

Method A Conditional formatting rows or cells if two columns equal

In Excel, you can use the Conditional Formatting function to automatically shade the rows or cells if two columns equal.

1. Select the first list of data you want to compare to the second one, for instance, A2:A7, then click Home > Conditional Formatting > New Rule.

doc conditional formatting if equal 3

2. In the New Formatting Rule dialog, select Use a formula to determine which cells to format from Select a Rule Type section, then type =$A2=$B2 into the text box under Format values where this formula is true.

Tip: A2 is the first cell in the first list, and B2 is the first cell in the second list you want to compare to.
doc conditional formatting if equal 4

3. Click Format in the New Formatting Rule dialog, then select a background color under Fill tab in the popping Format Cells dialog.
doc conditional formatting if equal 5

4. Click OK > OK to close the dialogs. Now the cells have been shaded if two columns equal.
doc conditional formatting if equal 6

Note: if you want to fill rows when two columns equal, select two lists as range, and then apply the New Formatting Rule dialog.
doc conditional formatting if equal 7



Method B Highlight and select cells if two columns equal

If you want to highlight the cells if two columns equal, and at the same time, to select the cells, you can use the Compare Cells feature of Kutools for Excel.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After free installing Kutools for Excel, please do as below:

1. Select the first list, then select the second list with holding Ctrl key, then click Kutools > Compare Cells to enable the Compare Cells dialog.
doc conditional formatting if equal 8

2. In the Compare Cells dialog, check Same cells option, check Fill backcolor or Fill font color check boxes, and select a color as you need.
doc conditional formatting if equal 9

3. Click Ok, now the cells have been selected and highlighted as well if two columns equal.
doc conditional formatting if equal 10


Sample File

Click to download sample file

Other Operations (Articles) Related To Conditioanl Formatting

Count/sum cells by colors with conditional formatting in Excel
Now this tutorial will tell you some handy and easy methods to quickly count or sum the cells by color with conditional formatting in Excel.

create a chart with conditional formatting in Excel
For example, you have a score table of a class, and you want to create a chart to color scores in different ranges, here this tutorial will introduce the method on solving this job.

Apply conditional formatting for each row
Sometimes, you may want to apply the conditional formatting for per row, except repeatedly setting the same rules for per row, there are some tricks on solving this job.

Conditional formatting stacked bar chart in Excel
This tutorial, it introduces how to create conditional formatting stacked bar chart as below screenshot shown step by step in Excel.

Search and highlight search results in Excel
In Excel, you can use the Find and Replace function to find a specific value, but do you know how to highlight the search results after searching? In this article, I introduce two different ways to help you search and highlight search results at the meanwhile in Excel.


  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • 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!
officetab bottom
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations