Hi,

I am comparing two columns and deleting the unique row if found in any of them. I compare columns A and C. However, sometimes it it possible that column C will be empty so I'd like to choose column D instead to compare with the column A. How can I do that? I tried the if condition but the code gets stuck in the loop. I first compare each row of column C with entire column A and delete unique, then compare each row of Column A with entire Column C and delete the unique if found. Here is the code:

Set Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
Last = Range("C" & Rows.Count).End(xlUp).row
For row = Last To 2 Step -1
    If Application.CountIf(Rng, Range("C" & row)) <> 1 Then
        Range("C" & row).Resize(, 18).Delete shift:=xlUp
    End If
Next row

Set Rng = Range(Range("C1"), Range("C" & Rows.Count).End(xlUp))
Last = Range("A" & Rows.Count).End(xlUp).row
For row = Last To 2 Step -1
    If Application.CountIf(Rng, Range("A" & row)) <> 1 Then
        Range("A" & row).Resize(, 2).Delete shift:=xlUp
    End If
Next row
The objective is to select Column D if the column C is empty, else continue with Column C. I'm stuck on this

Thanks!