P
phmckeever
As you see from the code, it finds occurrences of ‘ign’ and ‘leg’ in column
A, considered a match; it, then, checks that the ID numbers in column B are
identical.
Once these two conditions are met, it finds the cells in the ‘ign’ and ‘leg’
rows, ie c2 – ae3, and highlights the cells in the range that are different.
The last piece I need is to have the code skip the ‘ign’/’leg’ rows that do
not have a match, only one ‘ign’ or only one ‘leg’.
HERE IS THE CODE I HAVE:
Range("A1").Select
Set Record1 = Range("$b2")
Set Record2 = Range("$b3")
Range("A1").Select
Do While (Record1 <> "")
If (Record1 = Record2) Then
IngRow = Record1.Row
strRow1 = Trim$(Str$(IngRow))
strRow2 = Trim$(Str$(IngRow + 1))
Set rngAll = Range("$C" & strRow1 & ":$AE" & strRow2)
rngAll.FormatConditions.Delete
For x = 1 To rngAll.Columns.Count
strFormula = "=AND($A" & strRow1 & "=""ign"", " & _
"$A" & strRow2 & "=""leg""," & _
"$B" & strRow1 & "=$B" & strRow2 & "," & _
rngAll.Cells(1, x).Address & "<>" & _
rngAll.Cells(2, x).Address & ")"
rngAll.Cells(1, x).Select
Selection.FormatConditions.Add _
Type:=xlExpression, Formula1:=strFormula
Selection.FormatConditions(1).Interior.ColorIndex = 6
rngAll.Cells(2, x).Select
Selection.FormatConditions.Add _
Type:=xlExpression, Formula1:=strFormula
Selection.FormatConditions(1).Interior.ColorIndex = 6
Next x
End If
Set Record1 = Record1.Offset(2, 0)
Set Record2 = Record2.Offset(2, 0)
Loop
This code works fine; I just need it to skip the unmatched rows. Thanks!
phmckeever
A, considered a match; it, then, checks that the ID numbers in column B are
identical.
Once these two conditions are met, it finds the cells in the ‘ign’ and ‘leg’
rows, ie c2 – ae3, and highlights the cells in the range that are different.
The last piece I need is to have the code skip the ‘ign’/’leg’ rows that do
not have a match, only one ‘ign’ or only one ‘leg’.
HERE IS THE CODE I HAVE:
Range("A1").Select
Set Record1 = Range("$b2")
Set Record2 = Range("$b3")
Range("A1").Select
Do While (Record1 <> "")
If (Record1 = Record2) Then
IngRow = Record1.Row
strRow1 = Trim$(Str$(IngRow))
strRow2 = Trim$(Str$(IngRow + 1))
Set rngAll = Range("$C" & strRow1 & ":$AE" & strRow2)
rngAll.FormatConditions.Delete
For x = 1 To rngAll.Columns.Count
strFormula = "=AND($A" & strRow1 & "=""ign"", " & _
"$A" & strRow2 & "=""leg""," & _
"$B" & strRow1 & "=$B" & strRow2 & "," & _
rngAll.Cells(1, x).Address & "<>" & _
rngAll.Cells(2, x).Address & ")"
rngAll.Cells(1, x).Select
Selection.FormatConditions.Add _
Type:=xlExpression, Formula1:=strFormula
Selection.FormatConditions(1).Interior.ColorIndex = 6
rngAll.Cells(2, x).Select
Selection.FormatConditions.Add _
Type:=xlExpression, Formula1:=strFormula
Selection.FormatConditions(1).Interior.ColorIndex = 6
Next x
End If
Set Record1 = Record1.Offset(2, 0)
Set Record2 = Record2.Offset(2, 0)
Loop
This code works fine; I just need it to skip the unmatched rows. Thanks!
phmckeever