ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comparing data based on two columns (https://www.excelbanter.com/excel-programming/300329-comparing-data-based-two-columns.html)

riggsd

Comparing data based on two columns
 
I've done a search through the forums here and haven't found what
need. I did get some help at another forum, but it took forever to ru
(longer than it would take to check manually) and management has als
added additional criteria.

What I need to do is compare two worksheets that should contain th
same data, but are sorted differently. Each worksheet is extracted fro
a different database hence the need to compare them. The number of row
in each worksheet will vary and can be anywhere from a couple o
hundred rows to several thousand rows (average 5,000). As a result,
cannot use ranges, instead it needs to stop when it reaches a blan
cell in the first worksheet.

Basically, there are two columns. The data in column B can b
duplicated up to four times (but could be more or less) but it wil
only be listed once for each item in column A. I need to have the dat
in both columns matched to the second worksheet. If both columns match
they should be set to green on both worksheets. If column B matches
but column A doesn't match, continue searching until found. If no
found, highlight columns A and B in first worksheet orange an
continue.

For example:

Worksheet A
R1 Filename1
R2 Filename1
R3 Filename1
R1 Filename2
R2 Filename2
R2 Filename3
R3 Filename4
R4 Filename4

Worksheet B
R1 Filename1
R2 Filename1
R2 Filename3
R3 Filename1
R3 Filename2
R3 Filename3
R4 Filename2
R4 Filename4

Do while not blank
In "P"
For columns 1 to 2
Start with row 2
Get data in column A
Get data in column B

In "B"
Find data matching P:B
If found, does B:A match P:A
If match, highlight cell in A and B green
Return to "P" and highlight cell in A and B green
If no match, continue searching for P:B
If not found, return to "P", highlight P:A and P:B in orange

Get next row in "P"

I know how its supposed to work, just not how to get it to work wit
Excel VBA. Since I won't be running the comparisons, it has to be
macro/VBA so that the users can run it with a couple of clicks - n
copying formulas, etc.

Thanks in advance.
-da

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:22 AM.

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