Checking for duplicates between two files with dynamic filename

pk107

New Member
Joined
Jan 29, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi All,
I am trying to use IF, ISERROR and MATCH functions together to find out Duplicates within the same column "C" between two files.
My problem is that the second filename (in this case Duplicate file.xlsx) is not fixed and it is up to the user to name this file in whatever way he/she wants.
What modification can I do to make this filename fully dynamic so that when the code is run it will ask to select the file from the location?

ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(MATCH(RC[-14],'[Duplicate file.xlsx]Sheet1'!R2C3:RC3,0)),"""",""Duplicate"")"

Full code as below:
Sub Daily_Report1()
'
' Daily_Report1 Macro
' Daily Report Jan21
'
' Keyboard Shortcut: Ctrl+Shift+N
'
Columns("F:F").Select
Selection.TextToColumns Destination:=Range("F1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Columns("C:C").Select
Selection.TextToColumns Destination:=Range("C1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True

Range("Q1").Select
ActiveCell.FormulaR1C1 = "Duplicate or not"
Range("Q2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(MATCH(RC[-14],'[Duplicate file.xlsx]Sheet1'!R2C3:RC3,0)),"""",""Duplicate"")"
Range("Q2").Select
Selection.AutoFill Destination:=Range("Q2:Q" & Range("E" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Watch MrExcel Video

Forum statistics

Threads
1,127,610
Messages
5,625,814
Members
416,138
Latest member
Pizzaman22

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
Top