MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Nov 26th, 2008, 06:37 PM   #1
mgirvin
 
Join Date: Dec 2005
Location: Seattle, WA
Posts: 321
Default Compare 2 Lists, Create list of Unique Values

Dear Smartest Excelers in The World,

I have List1 in column A starting in cell A1:

List1
Sioux
Red
Chin
Phil
Abe


I have List2 in column C starting in cell C1:

List2
Sioux
Red
Sue
Chin
Phil
Abe
Mo

I am trying to create a third list in Column E starting in cell E1 that will extract the values in List2 that are not in List1. I want it to look like this:

Unique Records from List2 that are not in List1
Sue
Mo



Is there a way to put a formula in column E that will do this automatically? Although I am primarily interested in a formula, I might secondarily be interested in some VBA code.
__________________
Sincerely, Mike Gel Girvin
mgirvin is offline   Reply With Quote
Old Nov 26th, 2008, 07:00 PM   #2
Latchmaker
 
Join Date: Sep 2005
Location: Greensburg, Indiana
Posts: 61
Default Re: Compare 2 Lists, Create list of Unique Values

Try this VBA
Sub CreateUniqueList()

Range("D2").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-3],RC[-1])"
Selection.AutoFill Destination:=Range("D2:D8"), Type:=xlFillDefault
Range("D2:D10000").Select
Range("C1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="0"
Columns("C:C").Select
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.AutoFilter
Columns("D:D").Select
Selection.ClearContents
Range("E1").Select
ActiveCell.FormulaR1C1 = "List3"
Range("E1").Select
End Sub
__________________
I know I make mistakes, thats the beauty of #N/A, #VALUE and #NAME.
Latchmaker is offline   Reply With Quote
Old Nov 26th, 2008, 09:25 PM   #3
mgirvin
 
Join Date: Dec 2005
Location: Seattle, WA
Posts: 321
Default Re: Compare 2 Lists, Create list of Unique Values

Dear LatchMaker,

Thanks for your code! It works fine! Similarly, I have created a Macro but I used Advanced Filter and a True/False formula in the Macro.

What I am really after is a formula that I can put in the E column that will do this dynamically.

Any Formula idea, Excel Masters?
__________________
Sincerely, Mike Gel Girvin
mgirvin is offline   Reply With Quote
Old Nov 26th, 2008, 09:45 PM   #4
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 40,228
Default Re: Compare 2 Lists, Create list of Unique Values







List1List22
SiouxSiouxItems List2 Not In List1
RedRedSue
ChinSueMo
PhilChin
AbePhil
Abe
Mo


E1:

=SUMPRODUCT(1-ISNUMBER(MATCH(C2:C8,A2:A6,0)))

E2:

Control+shift+enter, not just enter...

Code:
=IF(ROWS($E$3:E3)<=$E$1,INDEX($C$2:$C$8,
   SMALL(IF(1-ISNUMBER(MATCH($C$2:$C$8,$A$2:$A$6,0)),
    ROW($C$2:$C$8)-ROW($C$2)+1),ROWS($E$3:E3))),"")
and copy down.
Aladin Akyurek is offline   Reply With Quote
Old Nov 26th, 2008, 09:51 PM   #5
mgirvin
 
Join Date: Dec 2005
Location: Seattle, WA
Posts: 321
Default Re: Compare 2 Lists, Create list of Unique Values

Dear Aladin,

Again, you come to the rescue!

I have been working on this for a few hours and I just came up with this formula in Column E for the set up as I described in the first post:

{=IF(ROWS(E$2:E2)<=COUNTA($C$2:$C$8)-COUNTA($A$2:$A$6),INDEX($C$2:$C$8,SMALL(IF(ISNA(MATCH($C$2:$C$8,OFFSET($A$2,0,0,COUNTA($C$2:$C$8)),0)),ROW($C$2:$C$8)-ROW($C$2)+1),ROWS(E$2:E2))),"")}

Now, I will go and try your formula!

Thanks!!!
__________________
Sincerely, Mike Gel Girvin
mgirvin is offline   Reply With Quote
Old Nov 26th, 2008, 10:42 PM   #6
mgirvin
 
Join Date: Dec 2005
Location: Seattle, WA
Posts: 321
Default Re: Compare 2 Lists, Create list of Unique Values

Dear Aladin,

As you can see from my formula in my above post, I used all the tricks I learned from the last solution you posted for me under the subject line "Reverse two-way lookup".

What I learned from you this time is an elegant method for an ISFALSE array:

1-ISNUMBER(MATCH($C$2:$C$8,$A$2:$A$6,0))

Totally awesome!

Thanks!
__________________
Sincerely, Mike Gel Girvin
mgirvin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 04:49 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes