Hi,
After several attempts, there is no result for 2nd method using Each Cell For Next Loop based on the following codes.
Option Explicit
Sub CompareCells()
' Looping method using Counter For Next Loop
Dim i As Integer
Calculate
For i = 1 To Range("New").Cells.Count
If Range("New").Cells(i) > Range("Old").Cells(i) Then
Range("New").Cells(i).Interior.Color = vbYellow
Else
Range("New").Cells(i).Interior.Color = vbCyan
End If
Next i
End Sub
Sub CompareCells1()
' Alternative Looping method by using Each Cell For Next Loop
Dim Cell As Range
Calculate
For Each Cell In Range("New")
If Range("New").Range(Cell.Address) > Range("Old").Range(Cell.Address) Then
Range("New").Range(Cell.Address).Interior.Color = vbYellow
Else
Range("New").Range(Cell.Address).Interior.Color = vbCyan
End If
Next Cell
End Sub
Any help will be much appreciated as I'm VBA beginner
Thanks in Advance
Regards
Len
After several attempts, there is no result for 2nd method using Each Cell For Next Loop based on the following codes.
Option Explicit
Sub CompareCells()
' Looping method using Counter For Next Loop
Dim i As Integer
Calculate
For i = 1 To Range("New").Cells.Count
If Range("New").Cells(i) > Range("Old").Cells(i) Then
Range("New").Cells(i).Interior.Color = vbYellow
Else
Range("New").Cells(i).Interior.Color = vbCyan
End If
Next i
End Sub
Sub CompareCells1()
' Alternative Looping method by using Each Cell For Next Loop
Dim Cell As Range
Calculate
For Each Cell In Range("New")
If Range("New").Range(Cell.Address) > Range("Old").Range(Cell.Address) Then
Range("New").Range(Cell.Address).Interior.Color = vbYellow
Else
Range("New").Range(Cell.Address).Interior.Color = vbCyan
End If
Next Cell
End Sub
Any help will be much appreciated as I'm VBA beginner
Thanks in Advance
Regards
Len