I wonder if somebody could help me complete the vba code. What I want to do is to Compare two values in two different columns (Correct, Compare). If they are equal you should copy a value from third column (Rank) into a fourth column (Output). The "group of Compare" is 39 rowsThe "group of Rank" is 39 rowsThe "group of Correct" is 13 rowsThe "group of Output" is 13 rows So the first loop is Compare (row 2-40), Rank (row 2-40), Correct (row 2-14),Output (row 2-14). Second loop Compare (row 41-79), Rank (row 41-79), Correct (row 15-27),Output (row 15-27) and so on. This code works for the first loop. After that it gets wrong.
Private Sub CommandButton3_Click()
Dim LastRow
Dim i
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = 2 To LastRow
Cells(i, 7) = Application.WorksheetFunction.VLookup(Cells(i, 6), Columns("D:E"), 2, 0)
Next i
End Sub
