Marking found records in Workbook A from Target List in Workbook B

U

u473

From Target List in Workbook B column A, (Activity ID),
I need to yellow shade column A (Activity ID), in workbook A
for any matching Activity ID's.
..
Detail : Workbook B, has first to be cleaned up by deleting the first
5 rows and deleting
any remaining rows that have empty cells in column A, through the last
row.
..
Workbook A : fields definition (Maximum 2,000 records)
A B C
Activity ID Activity Description Other data
..
Target List in Workbook B : fields definition (Maximum 50 records)
A B
Activity ID Status
..
Help appreciated
..
J.P.
 
M

marcus

Hi JP

Run this code from Workbook B, this is important. It assumes you have
Book A open at the time you run it. Also does not clean up the file
just looks at the filled range in WorkbookB col A and finds matches
from this point.

Take care

Marcus

Sub CheckMatches()

Dim RngCell As Range
Dim IsMatch() As Variant
Dim res As Variant
Dim lw As Long
Dim lr As Long
Dim X As Range
Dim wb As Workbook
Dim ws As Worksheet

lr = Range("A" & Rows.Count).End(xlUp).Row
Set wb = Workbooks("Book1.xls")
Set ws = wb.Sheets("Sheet1")
IsMatch() = Range("A2:A" & lr).Value
lw = ws.Range("A" & Rows.Count).End(xlUp).Row

Set X = ws.Range("A2:A" & lw)
For Each RngCell In X
res = Application.Match(RngCell.Value, IsMatch, 0)
If IsError(res) Then
'No Match
Else ' Match
RngCell.Interior.Color = vbYellow
End If
Next RngCell

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top