I have data wtih 21 rows & 6 columns. Wherein I need to compare a1 with a2 to f2 similarly ,b1,c1,d1,e1 & f1 with a2 to f2 and then increment row by 1 and continue the same process till end. If the result matches then highlight the previous row cell . if the result is already highlighted because of previous match then make it bold and then on next match underline it . My data is something like this
a b c d e f
1 2 5 7 4 3 9
2 5 4 5 5 7 4
3 2 3 7 8 9 12
4 1 8 9 7 5 8
I have the following vba which matches with a1=a2,b1=b2, c1=c2 and ignore b2=a1,c2=b1 and so on. Kindly guide me to correct the vba to make it bold & underline it with success matches while comparing previous row wtih nextrow
Sub colorCellMacro2()
Dim i As Long
Dim firstRow As Integer
Dim secondRow As Integer
firstRow = 1
secondRow = 2
Do While Cells(firstRow, 1) <> "" And Cells(secondRow, 1) <> ""
For col = 1 To 6
For row = 1 To 21
colval1 = Cells(firstRow, col).Value
colval2 = Cells(secondRow, col).Value
If colval1 = colval2 Then
Cells(firstRow, col).Select
End With
Next row
Next col
firstRow = firstRow + 1
secondRow = secondRow + 1
Loop
MsgBox "complete"
End Sub
a b c d e f
1 2 5 7 4 3 9
2 5 4 5 5 7 4
3 2 3 7 8 9 12
4 1 8 9 7 5 8
I have the following vba which matches with a1=a2,b1=b2, c1=c2 and ignore b2=a1,c2=b1 and so on. Kindly guide me to correct the vba to make it bold & underline it with success matches while comparing previous row wtih nextrow
Sub colorCellMacro2()
Dim i As Long
Dim firstRow As Integer
Dim secondRow As Integer
firstRow = 1
secondRow = 2
Do While Cells(firstRow, 1) <> "" And Cells(secondRow, 1) <> ""
For col = 1 To 6
For row = 1 To 21
colval1 = Cells(firstRow, col).Value
colval2 = Cells(secondRow, col).Value
If colval1 = colval2 Then
Cells(firstRow, col).Select
End With
Next row
Next col
firstRow = firstRow + 1
secondRow = secondRow + 1
Loop
MsgBox "complete"
End Sub