G
GettingThere
I am trying to determine if a row is a duplicate based on two criteria. This
is what I have so far, but it doesn't work. Any pointers much appreciated!
sub tester
Dim iLastRow As Long
Dim i As Long
Dim rName1 As Range
Dim rName2 As Range
Dim rTestRng As Range
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
' it's a dup if there are two rows in which columns C match AND
columns J ' match
Set rTestRng = Union(.Cells(i, "c"), .Cells(i, "j"))
If Application.CountIf(Union(.Range("c1:c" & iLastRow),
..Range("j1:j" & iLastRow)), rTestRng) = 2 Then
' do some stuff here
else ' do something else
end if
next i
end sub
is what I have so far, but it doesn't work. Any pointers much appreciated!
sub tester
Dim iLastRow As Long
Dim i As Long
Dim rName1 As Range
Dim rName2 As Range
Dim rTestRng As Range
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
' it's a dup if there are two rows in which columns C match AND
columns J ' match
Set rTestRng = Union(.Cells(i, "c"), .Cells(i, "j"))
If Application.CountIf(Union(.Range("c1:c" & iLastRow),
..Range("j1:j" & iLastRow)), rTestRng) = 2 Then
' do some stuff here
else ' do something else
end if
next i
end sub