Forum Discussion
ERBAE200
Jul 30, 2022Copper Contributor
Finding / marking errors with formula depending on two rows
Hello, I have attached an example file to understand my issue. I want to use a formula who is able to detect if a number in row A has more than one number in row B. Per each number in A only...
OliverScheurich
Jul 30, 2022Gold Contributor
Sub red()
Dim i As Long
Dim entryinA As Long
Dim entriesinB As Long
Range("A:B").Interior.ColorIndex = -4142
For i = 1 To 12000
If Cells(i, 1).Value = Cells(i + 1, 1).Value Then
entryinA = entryinA + 1
Else
entriesinB = Application.WorksheetFunction.CountA(Range(Cells(i - entryinA, 2), _
Cells(i, 2)))
If entriesinB > 1 Then
Range(Cells(i - entryinA, 1), Cells(i, 2)).Interior.ColorIndex = 3
Else
End If
entryinA = 0
End If
Next i
End Sub
Maybe with these lines of code. In the attached file you can click the button in cell E2 to run the code.