Compare and mark

emukiss10

Board Regular
Joined
Nov 17, 2017
Messages
201
Hello,

I need to open archive file and compare column F of active sheet and archive sheet for occurrence and mark in acive sheet in column A if something was found.



I have code to compare fields and mark differences but now I would like to mark dubles in ActiveSheet. Mayby someone could refactor it?




Code:
Dim WB1 As Workbook
Dim WB2 As Workbook


Set WB1 = ActiveWorkbook
Set WB2 = Workbooks.Open("C:\Archive.xlsx")

' the code above is just for poiters - does not apply to code below

   Dim Zl As Range
   Dim RngZ As Range
   
   With CreateObject("scripting.dictionary")
      For Each Zl In Sheets(2).Range("E2", Sheets(2).Range("E" & Rows.count).End(xlUp))
         If Not .Exists(Zl.Value) Then .Add Zl.Value, Nothing
      Next Zl
      For Each Zl In Sheets(1).Range("F2", Sheets(1).Range("F" & Rows.count).End(xlUp))
         If Not .Exists(Zl.Value) Then
            If RngZ Is Nothing Then
               Set RngZ = Zl
            Else
               Set RngZ = Union(RngZ, Zl)
            End If
         End If
      Next Zl
   End With
   If Not RngZ Is Nothing Then RngZ.EntireRow.Copy Sheets("PolisyPozaEru").Cells(Rows.count, "A").End(xlUp).Offset(1, 0)

Best Regards!
W.
 
Last edited:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,214,857
Messages
6,121,948
Members
449,056
Latest member
FreeCricketId

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top