Hi,
I have a wb that has several sheets but for ease lets assume it has only 2.
What I am looking to do is compare ws1.Range("A1") with ws2.Range("A1") .
Easy enough in itself but I want the code to do is then loop through a range("A2:D53") comparing each ws1 cell with the same cell on ws2.
Ive managed to do it by writing following code
Set ws1 = Sheets("Input")
Set ws2 = Sheets("B2P")
For i = 2 To 53
Set Rng1 = ws1.Range("A" & i)
Set Rng2 = ws2.Range("A" & i)
If Rng1 = Rng2 Then
'do something
End if
Next i
End Sub
I have then repeated the code changing "A" to "B" and so forth to last column.
Is there a way to do this without code repetition.?
Any help much appreciated
I have a wb that has several sheets but for ease lets assume it has only 2.
What I am looking to do is compare ws1.Range("A1") with ws2.Range("A1") .
Easy enough in itself but I want the code to do is then loop through a range("A2:D53") comparing each ws1 cell with the same cell on ws2.
Ive managed to do it by writing following code
Set ws1 = Sheets("Input")
Set ws2 = Sheets("B2P")
For i = 2 To 53
Set Rng1 = ws1.Range("A" & i)
Set Rng2 = ws2.Range("A" & i)
If Rng1 = Rng2 Then
'do something
End if
Next i
End Sub
I have then repeated the code changing "A" to "B" and so forth to last column.
Is there a way to do this without code repetition.?
Any help much appreciated