Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CommandButton1_Click()
- Dim MasterList As New Dictionary
- Dim iListCount As Integer
- Dim x As Variant
- Dim iCtr As Integer
- Dim v As Variant
- Dim counter As Integer, i As Integer
- counter = 0
- With Sheets("Sheet2")
- .Range("M:M").ClearContents
- .Range("S:S").ClearContents
- Sheets("Sheet1").Range("C:C").Copy
- Sheets("Sheet2").Range("M1").Select
- ActiveSheet.Paste
- Sheets("Sheet1").Range("X:X").Copy
- Sheets("Sheet2").Range("S1").Select
- ActiveSheet.Paste
- Application.ScreenUpdating = False
- Application.Calculation = xlCalculationManual
- ' Get count of records in master list
- iListCount = .Cells(Rows.Count, "A").End(xlUp).Row
- 'Load Dictionary:
- For iCtr = 1 To iListCount
- v = .Cells(iCtr, "A").Value
- If Not MasterList.Exists(v) Then MasterList.Add v, ""
- Next iCtr
- 'Get count of records in list to be deleted
- iListCount = .Cells(Rows.Count, "M").End(xlUp).Row
- ' Loop through the "delete" list.
- For iCtr = iListCount To 1 Step -1
- If MasterList.Exists(.Cells(iCtr, "M").Value) Then
- .Cells(iCtr, "M").Delete shift:=xlUp
- .Cells(iCtr, "S").Delete shift:=xlUp
- End If
- Next iCtr
- End With
- Application.ScreenUpdating = True
- Application.Calculation = xlCalculationAutomatic
- MsgBox "Done!"
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement