VBA code to import data, doing lookups to detect duplicates I have an import macro, which creates ID by concatenating cells, then I compare using VLOOKUP with another sheet if any duplicate found.

It's running very slowly, so I want to know better ways to optimize this code, because once finished, I will need to add another "for" for to handle duplicates found and compare dates. 

It's one of my first macros in VBA, so I'm sure there are a lot of ways to improve the performance.

Sub ImportData()

Dim wb1 As Workbook
Dim wb2 As Workbook
Dim slr As Long
Dim dlr As Long
Dim Tlr As Long

Set wb1 = ActiveWorkbook

FileToOpen = Application.GetOpenFilename _
(Title:="Select import file", _
FileFilter:="Microsoft Excel Workbooks (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm")

If FileToOpen = False Then
    MsgBox "No File Specified.", vbExclamation, "ERROR"
    Exit Sub
Else
    Set wb2 = Workbooks.Open(Filename:=FileToOpen)
    slr = wb2.Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row

    wb2.Worksheets("Sheet1").Range("A8:S" &amp; slr).Copy _
    wb1.Worksheets("INPUT_DATA").Range("A2")
End If

    wb2.Close savechanges:=False

    dlr = wb1.Worksheets("INPUT_DATA").Cells(Rows.Count, 1).End(xlUp).Row
    wb1.Worksheets("INPUT_DATA").Range("A2:S" &amp; dlr).ClearFormats

    For cell = 2 To dlr
        Cells(cell, 20).Formula = "=CONCAT(RC[-19], ""__"",RC[-18])"
    Next

    'check duplicate values before import to TOTAL_DATA
    Tlr = wb1.Worksheets("TOTAL_DATA").Cells(Rows.Count, 1).End(xlUp).Row
    countMatch = 0
    countUnmatch = 0
    For cell = 2 To dlr
        Cells(cell, 21).Formula = "=IF(ISNA(VLOOKUP(RC[-1],TOTAL_DATA!C30,1,FALSE)), ""No"", ""Yes"")"
            If Cells(cell, 21).Value = "Yes" Then
                Cells(cell, 20).Font.Color = vbRed
                countMatch = countMatch + 1
            Else
                Range("A" &amp; cell, "T" &amp; cell).Cut Destination:=wb1.Worksheets("TOTAL_DATA").Range("A" &amp; Tlr + 1)
                Tlr = Tlr + 1
                countUnmatch = countUnmatch + 1
            End If
    Next cell

    If countMatch &gt; 0 Then
            MsgBox "Found duplicates!!" &amp; vbCr &amp; "Number of duplicates : " &amp; countMatch &amp; _
            vbCr &amp; "Duplicate items were keep at INPUT_DATA" &amp; vbCr &amp; _
            "Loaded succesfully : " &amp; countUnmatch &amp; " items", vbExclamation
    Else
            MsgBox "Loaded succesfully : " &amp; countUnmatch &amp; " items"
    End If
End Sub
```
This should be twice as fast:

dlr = wb1.Worksheets("INPUT_DATA").Cells(Rows.Count, 1).End(xlUp).Row
wb1.Worksheets("INPUT_DATA").Range("A2:S" &amp; dlr).ClearFormats

'check duplicate values before import to TOTAL_DATA
    Tlr = wb1.Worksheets("TOTAL_DATA").Cells(Rows.Count, 1).End(xlUp).Row
    countMatch = 0
    countUnmatch = 0

For cell = 2 To dlr
    Cells(cell, 20).Formula = "=CONCAT(RC[-19], ""__"",RC[-18])"

    Cells(cell, 21).Formula = "=IF(ISNA(VLOOKUP(RC[-1],TOTAL_DATA!C30,1,FALSE)), ""No"", ""Yes"")"
    If Cells(cell, 21).Value = "Yes" Then
        Cells(cell, 20).Font.Color = vbRed
        countMatch = countMatch + 1
    Else
        Range("A" &amp; cell, "T" &amp; cell).Cut Destination:=wb1.Worksheets("TOTAL_DATA").Range("A" &amp; Tlr + 1)
        Tlr = Tlr + 1
        countUnmatch = countUnmatch + 1
    End If
Next cell


Because in here we loop only once from 2 to dlr.