PC Review


Reply
Thread Tools Rate Thread

Comparing to tables of data to confirm they are the same or not

 
 
Roger on Excel
Guest
Posts: n/a
 
      8th Dec 2009
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 With Quote
 
 
 
 
Otto Moehrbach
Guest
Posts: n/a
 
      8th Dec 2009
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" <(E-Mail Removed)> wrote in message
news:E959D1B3-9BBC-4A09-BA00-(E-Mail Removed)...
> 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 With Quote
 
Lionel H
Guest
Posts: n/a
 
      9th Dec 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing data between two tables GLT Microsoft Access Queries 3 1st Feb 2010 02:28 PM
Comparing data between 2 tables SHETTY Microsoft Access Form Coding 1 5th Jun 2008 04:35 PM
Comparing data in two different tables =?Utf-8?B?TGF2YXRyZXNz?= Microsoft Access VBA Modules 3 14th Nov 2006 06:40 PM
Comparing data in tables News Group Microsoft Access Getting Started 0 23rd May 2006 03:41 PM
Comparing data in tables Gerrym Microsoft Excel Misc 2 3rd Mar 2005 08:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:14 AM.