Comments on: This should be simple in Excel right?
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right/
Comments on Ask MetaFilter post This should be simple in Excel right?Thu, 08 Apr 2010 15:43:04 -0800Thu, 08 Apr 2010 15:43:04 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: This should be simple in Excel right?
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right
Excel help. In column A I have several thousand numbers. In column B I have several thousand more numbers, some of which are in column A. I would like column C to contain the numbers from column A that are NOT in column B. I would also like column D to contain the numbers from column B that are NOT in column A.post:ask.metafilter.com,2010:site.150680Thu, 08 Apr 2010 15:33:47 -0800BigVACubexcelcolumnnumbersBy: Jacqueline
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158449
In column C: =IF(A1=B1, "", A1)<br>
<br>
In column D: =IF(A1=B1, "", B1)<br>
<br>
Drag down to fill all the rows of columns C and D.<br>
<br>
Let me know if that does what you want.comment:ask.metafilter.com,2010:site.150680-2158449Thu, 08 Apr 2010 15:43:04 -0800JacquelineBy: Jacqueline
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158451
(oh, that example assumes you're starting on row 1 with no header row, if you're starting on a different row change the 1s to the row number)comment:ask.metafilter.com,2010:site.150680-2158451Thu, 08 Apr 2010 15:44:09 -0800JacquelineBy: BigVACub
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158460
I should have specified, the numbers are in no particular order (and even if I sort both columns, they still won't line up on the same row). So number 10 might be on row 5 of Column A, and row 6 of Column B. I don't want the number 10 to show up in either C or D since its in both A and B.comment:ask.metafilter.com,2010:site.150680-2158460Thu, 08 Apr 2010 15:49:06 -0800BigVACubBy: defcom1
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158462
Column C:<br>
=IF(ISNA(MATCH(A1,$B$1:$B$<em>end</em>,0)),A1,"") <br>
<br>
If you copy this down, will take the first value in A, look for it in B. If it's a match, a blank will appear in C, otherwise A will appear. Drag this down the entire length of A.<br>
<br>
This will not sort out duplicates in A. <br>
<br>
Column D:<br>
=IF(ISNA(MATCH(B1,$A$1:$A$<em>end<em>,0)),B1,"")<br>
<br>
Same idea for D. <br>
<br>
Oh, A<em>end</em> and B<em>end<br>
</em> is the bottom of the respective column. You can also just use A:A and B:B, sometimes that makes things slower though.</em></em>comment:ask.metafilter.com,2010:site.150680-2158462Thu, 08 Apr 2010 15:49:58 -0800defcom1By: defcom1
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158466
Oops, forgot to close italics bracket.<br>
=IF(ISNA(MATCH(B1,$A$1:$A$<em>end</em>,0)),B1,"")<br>
<br>
Same idea for D.<br>
<br>
Oh, A<em>end</em> and B<em>end</em><br>
is the bottom of the respective column. You can also just use A:A and B:B, sometimes that makes things slower though.<br>
<br>
Don't forget the dollar signs. That locks column values, so when you drag the formula down, the range doesn't change.comment:ask.metafilter.com,2010:site.150680-2158466Thu, 08 Apr 2010 15:52:03 -0800defcom1By: greatgefilte
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158469
I think Jacqueline's answer assumes that the numbers that match are in the same row in A and B... If they're not, you can try something like this: (there's probably an easier way of doing it, but I haven't found it yet)<br>
<br>
In C: =isna(match(a1,$b1:$b$X,0)<br>
In D: =isna(match(b1,$a1:$a$X,0)<br>
(Replace X with the last row of numbers in B and A, respectively...<br>
Paste into all rows in C and D.<br>
<br>
Then, use AutoFilter. In column C, select only the TRUE values, then copy the filtered list from column A to another sheet. Reset the filter for column C, and in column D, select only the TRUE values. Do the same thing with column B (copy to a new sheet). Turn off AutoFilter, then copy the columns from the new sheet back into the original as C and D.<br>
<br>
Like I said, there's probably a better way...comment:ask.metafilter.com,2010:site.150680-2158469Thu, 08 Apr 2010 15:53:55 -0800greatgefilteBy: greatgefilte
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158472
And....defcom posted the better way... :)comment:ask.metafilter.com,2010:site.150680-2158472Thu, 08 Apr 2010 15:55:27 -0800greatgefilteBy: defcom1
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158483
Mines still got blanks in it, just realized. Easiest way off the top of my head is to copy the list to a new sheet, paste special 'values', use autofilter to show blanks, then delete those rows. There are more sophisticated ways, google 'delete blanks' in excel, but don't forget that the original list has formulas in it, it's not officially blank until you paste special values.comment:ask.metafilter.com,2010:site.150680-2158483Thu, 08 Apr 2010 16:03:00 -0800defcom1By: Simon Barclay
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158532
As an alternative to the method above, you can use the VLOOKUP function.<br>
<br>
But perhaps the most effective solution is to write a VBA macro.comment:ask.metafilter.com,2010:site.150680-2158532Thu, 08 Apr 2010 17:10:55 -0800Simon BarclayBy: nelvana
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158620
This assumes you're using Excel 2007.<br>
<br>
Change the color of Column B numbers to something other than black (automatic) - say, red. On a new sheet, copy Column A and Column B into one column. Put a title in the first row and then highlight the range of values.<br>
<br>
On the ribbon in the Home tab, click on the Conditional Formatting down arrow. Choose Highlight Cell Values .../Duplicate Values... and then choose the formatting (ie. Light Red Fill with Dark Red Text).<br>
<br>
Now click on your title in cell and then choose the Data tab, then Filter in the ribbon.<br>
<br>
Click the filter down arrow in cell A1 and choose Filter by Color/Filter by Font Color. If you choose Red, you're looking at unique values that were in Column B originally. If you choose Automatic, they would be unique values that were in Column A.<br>
<br>
The ability to filter easily by color is great in Excel 2007! If you're using something older, you could probably accomplish this but not with built-in menus as far as I know.comment:ask.metafilter.com,2010:site.150680-2158620Thu, 08 Apr 2010 18:34:02 -0800nelvanaBy: defcom1
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158736
VLOOKUP is dangerous. your numbers must be in ascending order. match(,,0) is much better. You can pair it with index() to do a vlookup in a list you can't order, it's more robust. <br>
<br>
I wish we could upgrade to 2007 at work...comment:ask.metafilter.com,2010:site.150680-2158736Thu, 08 Apr 2010 21:07:32 -0800defcom1By: nelvana
http://ask.metafilter.com/150680/This-should-be-simple-in-Excel-right#2158757
<small><b>defcom1</b>, I don't believe you need to have the numbers in ascending order unless you want Excel to find the closest match. If you want to find an exact match, you can have any order you want - you just need to specify the range lookup as FALSE. I use VLOOKUP all the time on large spreadsheets and it works great but I am always looking for an exact match.</small>comment:ask.metafilter.com,2010:site.150680-2158757Thu, 08 Apr 2010 21:47:54 -0800nelvana