I have a workbook with three worksheets
Sheet 1: Column 1- name column 2- check1 column 3- check 2
Sheet2: column 1- name column2- 10 of that row and the next 2 rows would contain some details of this name
I have to compare check1 and check2, and for whatever names check1 is not equal to check2, I have to make the rows of that name in sheet2 red in colour and copy these rows to sheet3.
following is the code that i wrote. But this is not making the second comparison(comparing names in sheet1 and sheet2) properly.
Can someone help me in this? Please
Sheet 1: Column 1- name column 2- check1 column 3- check 2
Sheet2: column 1- name column2- 10 of that row and the next 2 rows would contain some details of this name
I have to compare check1 and check2, and for whatever names check1 is not equal to check2, I have to make the rows of that name in sheet2 red in colour and copy these rows to sheet3.
following is the code that i wrote. But this is not making the second comparison(comparing names in sheet1 and sheet2) properly.
Code:
Sub routing_change()
Dim n As Long, a As Long, i As Long, k As Long, m As Long, l As Long, re As Long
Dim j As Integer
k = 12: m = 12: a = 1
With Worksheets("Sheet1")
n = .Range("A2", .Range("A2").End(xlDown)).Count
End With
With Worksheets("Sheet2")
re = .Range("B2", .Range("B2").End(xlDown)).Count
End With
For i = 2 To n + 1
If StrComp(Worksheets("Sheet1").Cells(i, 2), Worksheets("Sheet1").Cells(i, 4)) = 0 Then
Else
For j = 2 To re + 1 Step 3
If StrComp(Worksheets("Sheet1").Cells(i, 3), Worksheets("Sheet2").Cells(j, 2)) = 0 Then
Worksheets("Sheet2").Activate
With Rows(j & ":" & j).Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Rows(j+1&":"&j+1).Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Rows(j+2&":"&j+2).Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Exit For
End If
Next j
End If
Next i
end Sub
Can someone help me in this? Please