Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, how do I compare column A in Workbook 1 with column A in Workbook 2 and
highlight the entries in Workbook 1 that are found in Workbook 2 ? Regards Dylan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dylan
The code below would be one way of doing it or at least give you an idea where to start. Option Explicit Sub FindAndMarkDups() Dim WkBk1 As Workbook Dim WkBk2 As Workbook Dim i As Integer Dim SearchFor As String Dim FoundCell Set WkBk1 = Workbooks("Book1.xls") Set WkBk2 = Workbooks("Book2.xls") With WkBk1.Sheets("Sheet1") ..Activate For i = 1 To [A65535].End(xlUp).Row SearchFor = .Cells(i, 1).Value WkBk2.Sheets("Sheet1").Activate Set FoundCell = [A:A].Find(What:=SearchFor, LookAt:=xlWhole) If Not FoundCell Is Nothing Then ..Cells(i, 1).Interior.Color = vbRed End If Next ..Activate End With End Sub Hope this helps Steve |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Steve, it works perfectly.
Dylan "Incidental" wrote: Hi Dylan The code below would be one way of doing it or at least give you an idea where to start. Option Explicit Sub FindAndMarkDups() Dim WkBk1 As Workbook Dim WkBk2 As Workbook Dim i As Integer Dim SearchFor As String Dim FoundCell Set WkBk1 = Workbooks("Book1.xls") Set WkBk2 = Workbooks("Book2.xls") With WkBk1.Sheets("Sheet1") ..Activate For i = 1 To [A65535].End(xlUp).Row SearchFor = .Cells(i, 1).Value WkBk2.Sheets("Sheet1").Activate Set FoundCell = [A:A].Find(What:=SearchFor, LookAt:=xlWhole) If Not FoundCell Is Nothing Then ..Cells(i, 1).Interior.Color = vbRed End If Next ..Activate End With End Sub Hope this helps Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
compare 5 columns of text and highlight duplicates based on repeti | Excel Worksheet Functions | |||
Compare data in 2 workbooks and highlight differences in red | Excel Worksheet Functions | |||
Highlight duplicates | Excel Programming | |||
Compare two worksheets and Highlight duplicates in each | Excel Programming | |||
compare two columns within a worksheet, then highlight duplicates | Excel Worksheet Functions |