Change the file path to suit.
Sub Duplicate_Text_Files()
Dim strPath As String
Dim strFile As String
Dim FF As Long
Dim strData As String
strPath = "C:\Test\N\"
FF = FreeFile()
strFile = Dir(strPath & "*.txt")
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
Do Until strFile = ""
Open strPath & strFile For Input As #FF
Line Input #FF, strData
Close #FF
.Item(strFile) = strData
strFile = Dir
Loop
If .Count > 0 Then
Application.ScreenUpdating = False
Range("A1").Resize(.Count).Value = Application.Transpose(.Keys)
Range("B1").Resize(.Count).Value = Application.Transpose(.Items)
Range("C1").Resize(.Count).FormulaR1C1 = "=IF(COUNTIF(C2,RC2)>1,""Duplicate"","""")"
Range("C1").Resize(.Count).Value = Range("C1").Resize(.Count).Value
Columns("A:C").AutoFit
Application.ScreenUpdating = True
Else
MsgBox strPath, vbExclamation, "No .txt Files Found"
End If
End With
End Sub
Bookmarks