问题
I'm trying to compare 2 columns but on 2 different sheets. One is using a query and pulling straight from a SQL database but the other is grabbing data from a query within Access. The queries are slightly different so the results aren't identical which is why i need to compare the 2 columns.
Each sheet has a column (job number) and all i want to do is create another column on each excel sheet that simply says "Yes" or "No" based on whether that job number appears on the other sheet. They won't be in the same cell on the other sheet so i need it to simply check the entire column so for example...
Does job number "123456" appear in column "F" on "Sheet 1"
回答1:
Welcome to SO.
Not sure how's your data stored, but I would use COUNTIF combined with an IF in this case:
COUNTIF
With COUNTIF you can count how many cells in a range (column F) contains the value 123456. If the result of the count is 0, it means that 123456 is not there. If the count is 1 or more, means it is.
As I said, I don't know how is your file (I mean the sheets name and stuff like that) but probably you'll need something like:
=IF(COUNTIF(F:F;123456)>0;"Yes";"No")
Please, note F:F will probably be in a different sheet so you need to select it and in the formula you will see something like =IF(COUNTIF(NameOFSeet!F:F,"123456")>0;"Yes";"NO")
. This is correct.
Hope this helps a little bit.
UPDATE: I did a fake dataset like this: 2 sheets, named Sheet1 and Sheet2. In Sheet1 I got some random numbers:
In Sheet2 in column H got random numbers too. Some of them are in Sheet1 but others aren't.
In the first image, in cell H5 I got this formula:
=IF(COUNTIF(Sheet2!$H$3:$H$28;Sheet1!G5)>0;"Yes";"No")
Drag down. It returns exactly what you need. It will work with 10000 entries too.
来源:https://stackoverflow.com/questions/59930317/excel-matching-entries-in-a-column-but-on-2-different-sheets