View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default How to compare two differnet cell ranges to see if they are thesa

Hi

As I don't know your data layout I have created this example, which
hopefully can help you.

Sub CompareRng()
Dim Test As Boolean
Dim Same As String
Dim Diff As String

Test = True

' Both data sets start in row 1
' Data set A start in column A
' Data set B start in column T

For r = 1 To 79
For c = 1 To 14
If Cells(r, c).Value < Cells(r, c + 19).Value Then
Test = False
End If
Next
If Test = True Then
If Same = "" Then
Same = r
Else
Same = Same & ", " & r
End If
Else
If Diff = "" Then
Diff = r
Else
Diff = Diff & ", " & r
End If
End If


Test = True
Next
msg = MsgBox("Rows " & Same & " are the same" & vbLf _
& vbLf & "Rows " & Diff & " are different", _
vbInformation, "Row check")
End Sub


Regards,

Per

On 16 Jan., 17:32, Tom wrote:
I have two *data charts on the same worksheet *with each chart containing 14
columns and 79 rows. Is there a way to compare the two cell by cell and then
output a "same" or "different" if and cell in the a row is different between
the two data charts? Does this have to be done cell by cell or can it be done
by ranges?