VBA: Remove duplicates from closed workbook

lunatu

Board Regular
Joined
Feb 5, 2021
Messages
77
Office Version
  1. 2010
Platform
  1. Windows
  2. Web
Hi,

Any ideas how to create a macro that will remove duplicates from a closed workbook?

Im copying rows from workbook to another workbook which is closed and at the same I need to remove duplicates.

The range in use is A:N and the duplicate values to be checked is in column N.

The macro to copy rows I have already solved.

Any ideas how to solve this?
Thanks in advance :)
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Please show the code you already have. It's not clear what you mean by "closed workbook" since I am unaware of any way to write data to a workbook without opening it. Maybe you mean that the workbook starts out closed and your code opens it.

One strategy for this is to use Advanced Filter to get a list of unique values. Or the code could just do it by brute force. But there is not not enough detail in your description to give you code specific to your situation.
 
Upvote 0
Hi,

this is the macro Im using for copying:

VBA Code:
Sub MasterData()
Dim LastRow As Integer, i As Integer, erow As Integer
LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, 15).Value = "Yes" Then
Range(Cells(i, 1), Cells(i, 14)).Select
Selection.Copy
Workbooks.Open Filename:="C:\Master.xlsx"

Worksheets("Changes").Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub

And it currently copies all rows with condition "Yes", but some of the rows already exists in master Excel so I need to remove duplicates at the same time.
 
Upvote 0

Forum statistics

Threads
1,215,646
Messages
6,125,999
Members
449,279
Latest member
Faraz5023

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