Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing to tables of data to confirm they are the same or not
I have a table with 5 columns and 60 rows which contains text and numerical
data. The table is in columns B,C,D,E,F. I would like to utilize a macro to compare this table with another table (in columns G,H,I,J,K) for differences and to return a True or False value (in cell A65) if they are the same or different. can anyone help? ThankYou, Roger |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing to tables of data to confirm they are the same or not
Roger
This little macro will compare B1:F60 with G1:K60 and will place False or True in A65 if a difference is found or not. Note that if there is a difference, the code will not check beyond the first difference found. HTH Otto Sub TestCompare() Dim i As Range Dim Good As Boolean Good = True For Each i In Range("B1:F60") If i < i.Offset(, 5) Then Good = False Exit For End If Next i Range("A65") = Good End Sub "Roger on Excel" wrote in message ... I have a table with 5 columns and 60 rows which contains text and numerical data. The table is in columns B,C,D,E,F. I would like to utilize a macro to compare this table with another table (in columns G,H,I,J,K) for differences and to return a True or False value (in cell A65) if they are the same or different. can anyone help? ThankYou, Roger |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing to tables of data to confirm they are the same or not
Roger,
Not sure why you just want a flag if the tables contains differences - you've then got to go find them! The following highlights the differing cells. (but puts you flag in as well in case you use it for some other purpose) Sub compare() Range("A65") = "True" 'Assume the answer true For i = 2 To 6 For j = 1 To 60 If Cells(j, i) = Cells(j, i + 5) Then Cells(j, i).Interior.ColorIndex = 4 'green Cells(j, i + 5).Interior.ColorIndex = 4 'green Else Cells(j, i).Interior.ColorIndex = 3 'red Cells(j, i + 5).Interior.ColorIndex = 3 'red Range("A65") = "False" 'go false if you ever come through here End If Next j Next i End Sub "Roger on Excel" wrote: I have a table with 5 columns and 60 rows which contains text and numerical data. The table is in columns B,C,D,E,F. I would like to utilize a macro to compare this table with another table (in columns G,H,I,J,K) for differences and to return a True or False value (in cell A65) if they are the same or different. can anyone help? ThankYou, Roger |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Comparing 2 tables | Excel Worksheet Functions | |||
Comparing pivot tables entries with data in another worksheet | Excel Programming | |||
Confirm Data from Other Cells | Excel Programming | |||
Comparing 2 pivot tables data using VBA | Excel Worksheet Functions | |||
Comparing data in tables | Excel Discussion (Misc queries) |