ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compare names in two different worksheets (https://www.excelbanter.com/excel-programming/277078-compare-names-two-different-worksheets.html)

excelnewbie

Compare names in two different worksheets
 
Hello,

Need help desperately! To simplify...

Sheet1 is made up of two columns:
Column A is Last Name
Column B is First Name

Sheet2 is made up of two columns:
Column A is Last Name
Column B is First Name

I need to write code that will compare Sheet1 Column A to Sheet 2
ColumnA and if there is a match then compare Sheet1 Column B to Sheet 2
Column B to make sure it is the same Last Name and First Name (same
row), then write the name next to any matches....and I don't want to
concatenate the cells. :confused:

My current code is looking for matches not taking into consideration
that the Last Name and First Name might not be on the same row for ex.

Set CompareRange = Workbooks("Names.xls"). _
Worksheets("Sheet2").Range("B3:B3800,C3:C3800")
For Each x In Selection
For Each y In CompareRange
If x = y Then x.Offset(0, 4) = x
Next y
Next x

If I have Smith Joe in Sheet 1 and in Sheet 2 I have a Smith Bob and a
Johnson Joe it will show up as if if found Smith Joe because it isn't
putting looking at them together??? I hope that makes sense.....



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


excelnewbie

Compare names in two different worksheets
 
Thank You soooo much Tom!!! It worked perfectly!!! You were right about
my ranges...I was in such a hurry in just trying to simplify my code
that I forgot to change that!

Thanks a million!! :D :D



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


excelnewbie

Compare names in two different worksheets
 
Thank you Jim!! I will try that too! :D :D



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 07:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com