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 Mar 22nd, 2002, 09:26 AM   #1
scottbro
New Member
 
Join Date: Feb 2002
Posts: 11
Default

hello,

I have two columns of data, which contain part numbers. I would like to compare the two colums to see if there are any of the same entries in each (ie- to see what, if any, part numbers exist in Column B that also exist in A) Anybody know a way to help identify this? Thanks
scottbro is offline   Reply With Quote
Old Mar 22nd, 2002, 09:34 AM   #2
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-03-22 08:26, scottbro wrote:
hello,

I have two columns of data, which contain part numbers. I would like to compare the two colums to see if there are any of the same entries in each (ie- to see what, if any, part numbers exist in Column B that also exist in A) Anybody know a way to help identify this? Thanks
=SUMPRODUCT(ISNUMBER(MATCH(A10:A13,B10:B13,0))+0)

the result of which is either 0 (meaning no common items) or >0 (meaning N types of items are common to both lists).

Aladin
Aladin Akyurek is offline   Reply With Quote
Old Mar 22nd, 2002, 09:41 AM   #3
scottbro
New Member
 
Join Date: Feb 2002
Posts: 11
Default

thanks...but how can I see which ones are matches? For example, is there someway to highlight those that match?
scottbro is offline   Reply With Quote
Old Mar 22nd, 2002, 09:43 AM   #4
Dave Hawley
Banned
 
Join Date: Feb 2002
Posts: 1,582
Default

Hi Scott

Conditional Formatting would do it quite easy.

http://www.ozgrid.com/Excel/Formulas.htm

Some examples here that could help.


You may also want to look at Data>Filter>Advanced Filter to get only uniques

Dave Hawley is offline   Reply With Quote
Old Mar 22nd, 2002, 09:50 AM   #5
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Quote:
On 2002-03-22 08:34, Aladin Akyurek wrote:
Quote:
On 2002-03-22 08:26, scottbro wrote:
hello,

I have two columns of data, which contain part numbers. I would like to compare the two colums to see if there are any of the same entries in each (ie- to see what, if any, part numbers exist in Column B that also exist in A) Anybody know a way to help identify this? Thanks
=SUMPRODUCT(ISNUMBER(MATCH(A10:A13,B10:B13,0))+0)

the result of which is either 0 (meaning no common items) or >0 (meaning N types of items are common to both lists).

Aladin
Hi All,

Slightly shorter:

{=SUM(COUNTIF(A10:A13,B10:B13))}
array entered

or

=SUMPRODUCT(COUNTIF(A10:A13,B10:B13))
entered normally

...would return the number of duplicate items found.

The suggestion to use Conditional Formatting to highlight the actual duplicates, paired with a count formula would work rather well, I would think.

Bye,
Jay
Jay Petrulis is offline   Reply With Quote
Old Mar 22nd, 2002, 09:52 AM   #6
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-03-22 08:41, scottbro wrote:
thanks...but how can I see which ones are matches? For example, is there someway to highlight those that match?
The formula I proposed gives you a diagnostic result in accordance with my interpretation of your original question.

You could use conditional formatting for the current question.

Using A10:A13 and B10:B13 as your two column ranges:

select A10:A13,
activate Format|Conditional Formatting,
choose 'Formula Is' for 'Condition 1',
enter in the formula box:

=COUNTIF($B$10:$B$13,A1)>0

activate Format,
select a color on the Patterns tab,
click OK, OK.

Highlighted cells in A-range indicates values that also occur at least one in B-range.

Aladin
Aladin Akyurek is offline   Reply With Quote
Old Mar 22nd, 2002, 09:54 AM   #7
Don C
Board Regular
 
Join Date: Feb 2002
Location: Louisville, KY
Posts: 72
Default

Or in a third column, you could use COUNTIF.

If Part List 1 is, let's say A1:A30 and Part List 2 is B1:B30, then in C2
=Countif($A$2:$A$30,B2)
and copy that down to C30.

A "1" in column C is a unique Part 2 number and any number >1 in column C is a Part 2 number found in Columnn A.
Don C is offline   Reply With Quote
Old Mar 22nd, 2002, 10:21 AM   #8
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Jay, that's right. When writing up in high speed, the prob of match getting out is, with me, slightly higher than that of countif.

Aladin
Aladin Akyurek is offline   Reply With Quote
Old May 8th, 2002, 05:47 AM   #9
Bikeit
New Member
 
Join Date: May 2002
Posts: 5
Default

Here is what I do that may be some use to you.
It is a Macro that allows you to mark things at the same time as identifying matches.
In this case there is a source sheet and two compare sheets.

Sub Find_Matching_Invoice_Numbers()

Dim Search_Invoice_Number As String
Dim Compare_Invoice_Number As String

Dim InputRow(3), InputCol(3), MarkerCol(3)
Dim Search_Sheet2RowReset
Dim Search_Sheet3RowReset
Dim DataSheets(3) As String
Dim Sheet_loop_counter
Dim DataFinish As String
Dim Check As String
Dim MatchWith As String

'Makesure that each Input Col has 'End' placed at the bottom VERY IMPORTANT
'else the macro will not stop

'Initialise variables
DataSheets(1) = "Latest Source Sheet" 'source sheet
DataSheets(2) = "Compare sheet one" 'search sheet
DataSheets(3) = "Compare sheet two" 'search sheet

'Input rows and cols to be determined by user.
InputRow(1) = 6
InputCol(1) = 1
MarkerCol(1) = 12

InputRow(2) = 4
Search_Sheet2RowReset = InputRow(2)
InputCol(2) = 2
MarkerCol(2) = 10

InputRow(3) = 8
Search_Sheet3RowReset = InputRow(3)
InputCol(3) = 2
MarkerCol(3) = 8

DataFinish = False

Do 'outer loop Until DataFinish = True

Sheets(DataSheets(1)).Select
Cells(InputRow(1), InputCol(1)).Select

Search_Invoice_Number = ActiveCell.Value

If Search_Invoice_Number = "End" Then
DataFinish = True
Exit Do
End If


For Sheet_loop_counter = 2 To 3 'Note if you want to just compare one sheet against the other the reduce the loop e.g. 2 to 2.

Check = True

Sheets(DataSheets(Sheet_loop_counter)).Select

Do ' inner loop Until Check = False

Cells(InputRow(Sheet_loop_counter), InputCol(Sheet_loop_counter)).Select
Compare_Invoice_Number = ActiveCell.Value

If Compare_Invoice_Number = "End" Then
Check = False ' Set value of flag to False.
Exit Do
ElseIf Search_Invoice_Number = Compare_Invoice_Number Then
Selection.Font.ColorIndex = 3
Selection.Font.Bold = True 'set found cell text to bold red
Cells(InputRow(Sheet_loop_counter), MarkerCol(Sheet_loop_counter)).Select
ActiveCell = "Match with source file"

Sheets(DataSheets(1)).Select
Cells(InputRow(1), InputCol(1)).Select
Selection.Font.ColorIndex = 3
Selection.Font.Bold = True 'set cell in source text to bold red
Cells(InputRow(1), MarkerCol(1)).Select
MatchWith = "Match with "
MatchWith = MatchWith + DataSheets(Sheet_loop_counter)
ActiveCell = MatchWith

Check = False ' Set value of flag to False.
Exit Do
End If

InputRow(Sheet_loop_counter) = InputRow(Sheet_loop_counter) + 1

Loop Until Check = False ' Exit inner loop immediately.


Next Sheet_loop_counter

InputRow(1) = InputRow(1) + 1
InputRow(2) = Search_Sheet2RowReset
InputRow(3) = Search_Sheet3RowReset

Loop Until DataFinish = True

End Sub




Bikeit 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 -4. The time now is 02:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 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