How do I Compare Two Columns in MS Excel?
Excel provides several ways to compare values in two spreadsheet columns. You can highlight cells that are the same, or write a simple formula to compare the cells column by column. Either method can give you a clear visual indication of which cells are the same, or in case of numerical values, which cells are greater than, less than or equal to any others.
Conditional Formatting to Locate Duplicate Values
Highlight the two columns you want to compare.
Click the "Conditional Formatting" drop-down menu in the Home tab.
Click "Highlight Cell Rules," then "More Rules...."
Click "Format only unique or duplicate values" and choose whether to format all duplicate or all unique values in the drop-down menu labeled "Format all:".
Click the "Format" button and set the font, border, and fill options to change the look of the cells you specified. Click "OK" to apply the conditional formatting.
Formula to Compare Values
Choose a blank cell in a third column to compose a comparison formula. If your data begins in cells A1 and B1, use C1 for the first formula cell.
Type an IF formula, which begins "=IF". Consider whether you want to compare the value in A1 to the value in B1 or whether you want to indicate if they are equal, or not equal.
Add parentheses and a simple equation to the IF formula. If you want a visual indication that B1 is greater than A1, type "(A1
Add a comma after the simple equation, inside the parentheses, to tell Excel you're finished with the "if" part of the formula.
Move on to the "then" part of the statement. IF functions contain three parts. The first part the condition -- for example, A1>B1. The second part is the cell value if the condition is met -- the "true" value, if A1 is greater than B1. The third part is the cell value if the condition isn't met -- the "false" value, if A1 isn't greater than B1. Type "Greater", with the quotation marks, after the comma -- or substitute another word, whatever you want to see to indicate the comparison. Type another comma, then "Less than", again with quotes, and close the parentheses -- or, again, substitute another word. Using the same example, the formula now reads: =IF(A1>B1,"Greater", "Less than")Press "Enter."
Copy the formula from C1 and paste it into C2, C3 and as far down as the A1 and B1 cells you want to compare go. As you paste the formula into each cell, it will immediately display the result of the formula for the A and B cells in that row.
Use conditional formatting, if you want, to highlight all the true or false values in column C. The "Highlight Cell Rules" option labeled "Text that contains..." option lets you set the format for the text you specify.