Hello everyone,
I'm having difficulty with how to make a VBA, which compares all the values of a worksheet in another.
I tried to do it this way, but it didn't work:
Thanks for listening
I'm having difficulty with how to make a VBA, which compares all the values of a worksheet in another.
I tried to do it this way, but it didn't work:
VBA Code:
Sub CompareSheets()
Dim RowSheet1 As Long
Dim RowSheet2 As Long
RowSheet2 = 1
While Sheet2.Range("A" & RowSheet2).Value <> ""
RowSheet1 = 1
While Sheet2.Range("A" & RowSheet1).Value <> ""
If Sheet1.Range("A" & RowSheet1).Value = Sheet2.Range("A" & RowSheet2).Value Then
If Sheet1.Range("B" & RowSheet1).Value <> Sheet2.Range("B" & RowSheet2).Value Then
If Sheet1.Range("C" & RowSheet1).Value <> Sheet2.Range("C" & RowSheet2).Value Then
If Sheet1.Range("D" & RowSheet1).Value <> Sheet2.Range("D" & RowSheet2).Value Then
If Sheet1.Range("E" & RowSheet1).Value <> Sheet2.Range("E" & RowSheet2).Value Then
If Sheet1.Range("F" & RowSheet1).Value <> Sheet2.Range("F" & RowSheet2).Value Then
If Sheet1.Range("G" & RowSheet1).Value <> Sheet2.Range("G" & RowSheet2).Value Then
If Sheet1.Range("H" & RowSheet1).Value <> Sheet2.Range("H" & RowSheet2).Value Then
If Sheet1.Range("I" & RowSheet1).Value <> Sheet2.Range("I" & RowSheet2).Value Then
If Sheet1.Range("J" & RowSheet1).Value <> Sheet2.Range("J" & RowSheet2).Value Then
Sheet2.Range("A" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("B" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("C" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("D" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("E" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("F" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("G" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("H" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("I" & RowSheet2).Interior.Color = vbYellow
Sheet2.Range("J" & RowSheet2).Interior.Color = vbYellow
End If
End If
RowSheet1 = RowSheet1 + 1
Wend
RowSheet2 = RowSheet2 + 1
Wend
End Sub
Thanks for listening