Whether there's summer knocking on our doors or winter invading Westeros, we still work in Google Sheets and have to compare different pieces of tables with one another. In this article, I'm sharing ways of matching your data and giving away tips on doing that swiftly.
One of the tasks you may have is to scan two columns or sheets for matches or differences and identify them somewhere outside the tables.
I'll start with comparing two cells in Google Sheets. This way lets you scan entire columns row by row.
For this first example, you will need a helper column in order to enter the formula into the first row of the data to compare:
=A2=B2
If cells match, you'll see TRUE, otherwise FALSE. To check all cells in a column, copy the formula down to other rows:
=IF(A2=B2,"Match","Differ")
=IF(EXACT(A2,B2),"Match","Differ")
Where EXACT considers the case and looks for the complete identicals.
=IF(A2=B2,"Match","")
=IF(A2=B2,"","Differ")
=ArrayFormula(IF(A2:A=C2:C,"","Differ"))
This IF pairs each cell of column A with the same row in column C. If records are different, the row will be identified accordingly. What is nice about this array formula is that it automatically marks each and every row at once:
=ArrayFormula(IF(A2:A=C2:C,"Match",""))
Oftentimes you need to compare two columns in Google Sheets that belong inside a huge table. Or they can be entirely different sheets like reports, price lists, working shifts per month, etc. Then, I believe, you can't afford to create a helper column or it can be quite difficult to manage.
If this sounds familiar, don't worry, you can still mark the differences on another sheet.
Here are two tables with products and their prices. I want to locate all cells with different contents between these tables:
Start with creating a new sheet and enter the next formula into A1:
=IF(Sheet1!A1<>Sheet2!A1,Sheet1!A1&" | "&Sheet2!A1,"")
As a result, you will see only those cells that differ in contents. The formula will also pull records from both tables and separate them with a character you enter to the formula:
Of course, each of the examples above can be used to compare two columns from one or two tables or even match sheets themselves. However, there is a tool we created for this task that will benefit you a lot.
It will compare two Google sheets and columns for duplicates or uniques in 3 steps. Make it mark the found records with a status column (that can be filtered, by the way) or colour, copy or move them to another location, or even clear cells and delete entire rows with dupes whatsoever.
I used the add-on to find the rows from Sheet1 that are absent from Sheet2 based on Fruit and MSRP columns:
We've described all the tool's options on its help page for your better convenience. Feel free to try it for yourself and notice how much time it saves you. :)
Comparing two Google Sheets for differences and repeats is half the work, but what about missing data? There are special functions for this as well, for example, VLOOKUP. Let's see what you can do.
Imagine you have two lists of products (columns A and B in my case, but they can simply be on different sheets). You need to find those presented in the first list but not in the second one. This formula will do the trick:
=ISERROR(VLOOKUP(A2,$B:$B,1,0))
How does the formula work:
Thus, cells with FALSE is what you're looking for. Copy the formula to other cells to check each product from the first list:
=ISERROR(VLOOKUP(A2,Sheet2!$B:$B,1,0))
=ArrayFormula(ISERROR(VLOOKUP(A2:A10,$B:$B,1,0)))
Another smart way would be to count all appearances of the product from A2 in column B:
=IF(COUNTIF($B:$B, $A2)=0, "Not found", "")
If there's absolutely nothing to count, the IF function will mark cells with Not found. Other cells will remain empty:
Where there's VLOOKUP, there's MATCH. You know that, right? ;) Here's the formula to match products rather than count:
=IF(ISERROR(MATCH($A2,$B:$B,0)),"Not found","")
=IF(ISERROR(MATCH($A2,$B2:$B28,0)),"Not found","")
Your task may be a bit fancier: you may need to pull all missing information for the records common for both tables, for example, update prices. If so, you'll need to wrap MATCH in INDEX:
=INDEX($E:$E,MATCH($A2,$D:$D,0))
The formula compares fruits in column A with fruits in column D. For everything found, it pulls the prices from column E to column B.
As you may have guessed, another example would use the Google Sheets VLOOKUP function that we described some time ago.
If you're tired of formulas, you can use our Merge Sheets add-on to quickly match and merge two Google sheets. Alongside its basic purpose to pull the missing data, it can also update existing values and even add non-matching rows. You can see all changes in colour or in a status column that can be filtered.
There's one more standard way Google offers to compare your data - by colouring matches and/or differences via conditional formatting. This method makes all records you're looking for stand out instantly. Your job here is to create a rule with a formula and apply it to a correct data range.
Let's compare two columns in Google Sheets for matches and colour only those cells in column A that tally with cells in the same row in column C:
=A2=C2
=AND(A2=C2,ISBLANK(A2)=FALSE)
This will process entire columns and ignore empty cells.
=A2=INDIRECT("Sheet2!C2:C")
In this case, please make sure to specify the range to apply the rule to - A2:A10.
To highlight records that don't match cells on the same row in another column, the drill is the same as above. You select the range and create a conditional formatting rule. However, the formula here differs:
=A2<>C2
Again, modify the formula to make the rule dynamic (have it consider all newly added values in these columns):
=AND(A2=C2,ISBLANK(A2)=FALSE)
And use the indirect reference to another sheet if the column to compare with is there:
=A2<>INDIRECT("Sheet1!C2:C")
Of course, it's more likely the same records in your columns will be scattered. The value in A2 in one column will not necessarily be on the second row of another column. In fact, it may appear much later. Clearly, this requires another method of searching for the items.
To highlight unique values in each list, you need to create two conditional formatting rules for each column.
Color column A: =COUNTIF($C$2:$C$9,$A2)=0
Color column C: =COUNTIF($A$2:$A$10,$C2)=0
Here are the uniques I've got:
You can colour common values after slight modifications in both formulas from the previous example. Just make the formula count everything greater than zero.
Color dupes between columns in A only: =COUNTIF($C$2:$C$9,$A2)>0
Color dupes between columns in C only: =COUNTIF($A$2:$A$10,$C2)>0
Conditional formatting can be tricky sometimes: you may accidentally create a few rules over the same range or apply colors manually over cells with rules. Also, you have to keep an eye on all ranges: the ones you highlight via rules and those you use in rules themselves. All of these may confuse you a lot if you're not prepared and not sure where to look for the problem.
Luckily, our Compare columns or sheets is intuitive enough to help you match two columns within one table, two different tables on one sheet, or even two separate sheets, and highlight those uniques or dupes that may sneak into your data.
Here's how I colored uniques between two tables based on Fruit and MSRP columns using the tool:
All these methods are now at your disposal - experiment with them, modify and apply to your data. If none of the suggestions help your particular task, feel free to discuss your case in comments down below.
26 Responses to "How to compare data in two Google sheets or columns"
Hi,
I have to separate Google Spreadsheets. I need to make sure that they are identical. How can I compare the data between two separate spreadsheets?
Thank you,
Violet
Hi Violet,
To reference another spreadsheet, you need to use the IMPORTRANGE function.
Thus, your formula to compare two Google Sheets for differences may look like this:
=IF(Sheet1!A1<>IMPORTRANGE("link_to_your_2nd_spreadsheet","Sheet1!A1"),Sheet1!A1&" | "&IMPORTRANGE("link_to_your_2nd_spreadsheet","Sheet1!A1"),"")
Hi everyone,
Can somone please help me with which formula to use:
If Value in Column B is Column B minus Column A equal or greater than 2, then highlight Column B. So for example:
Column A Column B
100 103 = 103 is highlighted
100 101 = 101 is not highlighted
Thanks to whoever can answer this.
Hi Joy,
You need to create a conditional formatting rule with the following formula:
=($B2-$A2)>=2
Hi
I you have a user database with all names in the SHEET1 A:A but in SHEET2!A:A you only have some of the names, and same with SHEET3A:A and SHEET4!A:A
What if In SHEET1 you want the B:B collum to refference to what other sheet has the same name.
So if the First name in The Sheet 1 list is «John B» And «John B» is also the 13th name in the SHEET3. How do I get SHEET!B1 to say SHEET3 when SHEET!A1 says «John B» ?
If that makes any sence? What would the formula be in B1 (and dragged down for the rest of the sheet)
Hi Christian,
If I get your task correctly, this formula will help:
=IF(COUNTIF(Sheet3!$A:$A,A1)>0,"Sheet3","")
If you'd like to check in all 3 sheets at the same time and return the corresponding sheet name, try this one instead:
=IF(COUNTIF(Sheet2!$A:$A,A1)>0,"Sheet2",IF(COUNTIF(Sheet3!$A:$A,A1)>0,"Sheet3",IF(COUNTIF(Sheet4!$A:$A,A1)>0,"Sheet4","")))
Keep in mind that once the formula finds the value in Sheet2, it won't look in other sheets, it will return "Sheet2" right away. If the searched entry is absent from all three sheets, cells with formula will remain blank.
Hey Guys!
I'm having trouble doing this for two lists of names from a party. I have tried so many equations but still having trouble.
For example, in one column I have the full list of invited guests and then in column B I have all the people who have paid. I am trying to find who hasn't paid for their ticket to the party. Can someone help me out?
Cheers!
Hey Xavier,
It looks like you need to find those names in column A that are not in column B. This point of the article offers a short formula to solve this:
https://www.ablebits.com/office-addins-blog/2019/04/30/google-sheets-compare-two-sheets-columns/comment-page-1/#find-missing-data
If you'd rather use colours, please read through this paragraph:
https://www.ablebits.com/office-addins-blog/2019/04/30/google-sheets-compare-two-sheets-columns/comment-page-1/#highlight-both-lists
Make sure your names are written identically and there are no extra spaces or other chars in them.
Hi,
I have two separate Google Sheets, I need to take information from one sheet to the other. Using INDEX, MATCH how would I pull information over from one sheet to the other? MATCH("X",Sheet #2 URL, 0) doesn't seem to work
Thanks
Hi Patrick,
To do a v-lookup from another Google spreadsheet, you need to add IMPORTRANGE to your formula. Svetlana has provided the example here:
https://www.ablebits.com/office-addins-blog/2017/07/05/vlookup-google-sheets-example/comment-page-1/#comment-321671
I am trying to compare/list duplicates taken from a calendar.
Columns A and B are where people list their names and holiday dates. These columns got pretty bug quite quickly. To simplify looking for any available dates that you may want off I have created a drop down in J14 where you can select the month and which pulls the calendar for that month into cells J16:P21.
I have taken dates from the list in column B and highlight the corresponding dates in the calendar in J16:P21.
But, I want to list the people and the dates which they have booked off underneath the calendar.
To recap.... compare dates from column B2:B to the calendar J16:P21 and list duplicates and the corresponding name from column A2:A
Hello David,
For us to be able to help you better, please share a small sample spreadsheet with us (support@4-bits.com) with your source data and the result you expect to get. I kindly ask you to shorten the table to 10-20 rows.
Since we keep that email for file-sharing only, once you share the file, please confirm by replying here. Thank you.
Hi Natalia, I am hoping you will help me with a way to identify the common row fields from the two columns. They may not be in the same row and I want to identify the common in both columns appearing in anywhere in the two columns. All the fields in the individual columns are unique. Thanks for the opportunity to ask you this question.
Hi Sam,
Please look through this part of the article. It explains how to compare two columns for differences or duplicates no matter their position in columns.
I am trying to test for conditions in two different columns and count the number of times the condition is true in both columns.
For instance if the Value is "Closed" in column F and the Value is "M" in column K then count that row.
Todd,
this formula should help:
=COUNTIFS(F:F,"Closed",K:K,"M")
For more info please look through these blog post and comments.
Hi! This is very helpful!
I've used =ISERROR(VLOOKUP(C3,$G:$G,1,0)), and it gives me a FALSE if the C and G columns have the same name, and TRUE if it only exists in C.
Is there a way to list the True values in a single, tight column, excluding the False?
My project is a list of clients that need a specific task. If it has been accomplished, then the name is in G and C. G is all clients, C is a subset of those clients with the task completed. So, I'm looking for a list of clients who need the task. Thanks in advance,
Alex
Hi Alexander,
I'm sorry but your task is not entirely clear. Please consider sharing a small sample with us (support@4-bits.com) with your source data and the result you expect to get. I kindly ask you to shorten the table to 10-20 rows.
Since we keep that email for file-sharing only, once you share the file, please confirm by replying here. Thank you.
In the meantime, you can check our blog post devoted to Google Sheets VLOOKUP function. Perhaps, it'll help.
Please, i need a formula to remove duplicates from a large data of name and phone number from two different columns. Thanks
Hello Olumose,
I'm afraid the formula won't remove duplicates. You can use formulas to copy all unique or duplicate info to someplace else. Or create conditional formatting rules to colour duplicates where they reside.
However, there's a special tool that may help get rid of dupes. It offers 30 days of free use, so feel free to try it on your data:
https://gsuite.google.com/marketplace/app/remove_duplicates/347814268012
Hey, you seem super knowledgable and this is about as close as I've come to a solution for my problem.
I'm putting together a data set, which is basically a list of countries in row A, and I want to add data in form of entire columns - typically two columns where one is the list of countries and the other one is the data input. The issue is that some lists don't include all countries, for which I'd like to leave an empty row in that specific column of data.
Here's how I want it to look:
https://cdn3.imggmi.com/uploads/2019/10/22/3e9f91f0e882d2296a8f2b3e0cf40c59-full.png
On the right how it ends up, compared to my full list of countries:
https://cdn3.imggmi.com/uploads/2019/10/22/37545ca2a98a32471307627200bdeb09-full.png
I'm very greatful for any help of redirection towards a solution!
Hello Viking,
If I get it correctly, it looks like our Merge Sheets can help you. It pulls the related data from one table to another and adds missing rows with the rest of the countries.
In the end, you can simply sort the table by countries A>Z.
You can test the tool for 30 days for free to see if it suits your needs.
You're absolutely correct, Merge Sheets helped immensely and I appreciate you taking the time to help me out!
I am scraping data from the web in two columns and want to find the common values between the two columns (ie duplicates) and put them on the thrid column.
As I am scraping the data, I do not know how many cells I will have at any given time.
Any help appreciated!
Hello Nickolas,
If you want to use formulas, you need to know the exact number of duplicates because formulas won't supply you with additional rows.
So I'd advise you to try our Compare two sheets or columns tool. It will copy/move duplicate values to any place you select. If the sheet is short on rows, the tool will insert them along with the dupes.
Hello,
I have a Google Form people filled out, in total I need about 220 responses.
People have filled out their e-mail adresses and I want to check if everyone I sent it too actually filled it in.
If not, I can remind them to fill it out.
Is there a way I can crossreference the filled out email adresses with my imported list of e-mail adresses I sent the form too?
For example, I sent the email too hello1@gmail.com and hello2@gmail.com
I want to filter out which one hasnt filled out the form yet, so I can remind them.
Not sure if you will read it, but I'll give it a shot.