PC Review


Reply
Thread Tools Rate Thread

compring two data sets

 
 
Utkarsh
Guest
Posts: n/a
 
      17th Jan 2011
Hi

Currently I am using Excel to compare two datasets like

Sheet Sheet1
Name Date Type Amount
arc 01-01-2010 x 100
b 01-01-2007 y 25
a 01-03-2008 x 124
a 01-03-2010 x 76

and

Sheet Sheet2
Name Date Type Amount
arc ltd 01-01-2010 x 100
b 01-01-2007 y 20
a 01-03-2008 x 124
d 01-05-2007 x 100
a 01-02-2010 x 76
arc 01-01-2010 x 100

and generating an output like below in Sheet2

Name Date Type Amount All All but Value All but date All but name
Original value Original date Original Name
arc ltd 01-01-2010 x 100 $A$2 arc
b 01-01-2007 y 20 $A$3 25
a 01-03-2008 x 124 $A$4
d 01-05-2007 x 100
a 01-02-2010 x 76 $A$5 01-03-2010
arc 01-01-2010 x 100 $A$2

Wtih nerly 20,000 rows Excel takes a large amount of time to process
this. I m told that this can be done very fast with Access. The row
locations can be substituted by record number as track. Please advise
as to how I cn go about doing this in Access.

My VBA code for ready reference:

*************
Sub compare()
'clear columne
Sheets("Sheet2").Range("E2:K65536").ClearContents

'Find the last row to be evaluated for each sheet
Sheets("Sheet1").Select
lastrow1 = Range("A65536").End(xlUp).Row
Sheets("Sheet2").Select
lastrow2 = Range("A65536").End(xlUp).Row

Sheets("Sheet1").Select
For i = 2 To lastrow1
'Transfer each foled for a row into a variable
rec1 = Sheets("Sheet1").Cells(i, 1).Value
rec2 = Sheets("Sheet1").Cells(i, 2).Value
rec3 = Sheets("Sheet1").Cells(i, 3).Value
rec4 = Sheets("Sheet1").Cells(i, 4).Value
'MsgBox rec1 & rec2 & rec3 & rec4

Sheets("Sheet2").Select
For j = 2 To lastrow2

If Cells(j, 1).Value = rec1 And Cells(j, 2).Value = rec2 And _
Cells(j, 3).Value = rec3 And _
Cells(j, 4).Value = rec4 Then

Cells(j, 5).Value = Sheets("Sheet1").Range("A" & i).Address
Exit For
End If
If Cells(j, 1).Value = rec1 And Cells(j, 2).Value = rec2 And _
Cells(j, 3).Value = rec3 And _
Cells(j, 4).Value <> rec4 Then

Cells(j, 6).Value = Sheets("Sheet1").Range("A" & i).Address
Cells(j, 9).Value = Sheets("Sheet1").Range("D" & i).Value
Exit For
End If

If Cells(j, 1).Value = rec1 And Cells(j, 2).Value <> rec2 And _
Cells(j, 3).Value = rec3 And _
Cells(j, 4).Value = rec4 Then

Cells(j, 7).Value = Sheets("Sheet1").Range("A" & i).Address
Cells(j, 10).Value = Sheets("Sheet1").Range("B" & i).Value
Exit For
End If

If Cells(j, 1).Value <> rec1 And Cells(j, 2).Value = rec2 And _
Cells(j, 3).Value = rec3 And _
Cells(j, 4).Value = rec4 Then

Cells(j, 8).Value = Sheets("Sheet1").Range("A" & i).Address
Cells(j, 11).Value = Sheets("Sheet1").Range("A" & i).Value
End If


Next j
Next i

End Sub
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      17th Jan 2011
On Mon, 17 Jan 2011 09:27:46 -0800 (PST), Utkarsh <(E-Mail Removed)>
wrote:

>Hi
>
>Currently I am using Excel to compare two datasets like
>
>Sheet Sheet1
>Name Date Type Amount
>arc 01-01-2010 x 100
>b 01-01-2007 y 25
>a 01-03-2008 x 124
>a 01-03-2010 x 76
>
>and
>
>Sheet Sheet2
>Name Date Type Amount
>arc ltd 01-01-2010 x 100
>b 01-01-2007 y 20
>a 01-03-2008 x 124
>d 01-05-2007 x 100
>a 01-02-2010 x 76
>arc 01-01-2010 x 100
>
>and generating an output like below in Sheet2
>
>Name Date Type Amount All All but Value All but date All but name
>Original value Original date Original Name
>arc ltd 01-01-2010 x 100 $A$2 arc
>b 01-01-2007 y 20 $A$3 25
>a 01-03-2008 x 124 $A$4
>d 01-05-2007 x 100
>a 01-02-2010 x 76 $A$5 01-03-2010
>arc 01-01-2010 x 100 $A$2
>
>Wtih nerly 20,000 rows Excel takes a large amount of time to process
>this. I m told that this can be done very fast with Access. The row
>locations can be substituted by record number as track. Please advise
>as to how I cn go about doing this in Access.


A Query in Access would probably indeed work well. But your post is confusing:
"row locations can be substituted by record number as track" is meaningless to
me! What's "track"? How can you determine (based on the *CONTENT* of the
record, not its position) which record needs to be compared with which other
record? Did your Sheet2 example word wrap?
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
Utkarsh
Guest
Posts: n/a
 
      18th Jan 2011
To explain it more clearly there are two data sets separated by time
(let us say, OLD and NEW). I am trying to track changes between the
two data sets. Unfortunately, there is nothing that uniquely
identifies record and hence I need to compare based on content rther
than postion. That is why it is sueful for me to know which record in
OLD matches which record in NEW. Thanks

On Jan 17, 11:50*pm, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
> On Mon, 17 Jan 2011 09:27:46 -0800 (PST), Utkarsh <utkarsh.majmu...@gmail..com>
> A Query in Access would probably indeed work well. But your post is confusing:
> "row locations can be substituted by record number as track" is meaningless to
> me! What's "track"? How can you determine (based on the *CONTENT* of the
> record, not its position) which record needs to be compared with which other
> record? Did your Sheet2 example word wrap?
> --
>
> * * * * * * *John W. Vinson [MVP]
> *Microsoft's replacements for these newsgroups:
> *http://social.msdn.microsoft.com/For...-US/accessdev/
> *http://social.answers.microsoft.com/.../en-US/addbuz/
> *and see alsohttp://www.utteraccess.com- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      18th Jan 2011
On Mon, 17 Jan 2011 18:04:35 -0800 (PST), Utkarsh <(E-Mail Removed)>
wrote:

An Access table is an unordered "heap" of records, so position is irrelevant
in any case.

My question is: if you had two stacks of index cards with the information
printed on them, how would you match the cards? You say there is nothing that
uniquely identifies the record, and it seems that any one of the fields can be
erroneous. How can Access - or any computer program, or any person - identify
which record in Pile A should be compared with a given record in Pile B?

You can join by any field, or by any combination of fields; but there must be
SOME way (using those fields) to unambiguously match records, before you can
compare the values in those records.

>To explain it more clearly there are two data sets separated by time
>(let us say, OLD and NEW). I am trying to track changes between the
>two data sets. Unfortunately, there is nothing that uniquely
>identifies record and hence I need to compare based on content rther
>than postion. That is why it is sueful for me to know which record in
>OLD matches which record in NEW. Thanks
>
>On Jan 17, 11:50*pm, John W. Vinson
><jvinson@STOP_SPAM.WysardOfInfo.com> wrote:
>> On Mon, 17 Jan 2011 09:27:46 -0800 (PST), Utkarsh <utkarsh.majmu...@gmail.com>
>> A Query in Access would probably indeed work well. But your post is confusing:
>> "row locations can be substituted by record number as track" is meaningless to
>> me! What's "track"? How can you determine (based on the *CONTENT* of the
>> record, not its position) which record needs to be compared with which other
>> record? Did your Sheet2 example word wrap?
>> --
>>
>> * * * * * * *John W. Vinson [MVP]
>> *Microsoft's replacements for these newsgroups:
>> *http://social.msdn.microsoft.com/For...-US/accessdev/
>> *http://social.answers.microsoft.com/.../en-US/addbuz/
>> *and see alsohttp://www.utteraccess.com- Hide quoted text -
>>
>> - Show quoted text -

--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
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
Compring Dates? scoz Microsoft Excel Worksheet Functions 4 15th Jan 2009 05:01 PM
Excel graph 3 sets of data. 2 sets as lines 1 as column? AndyN Microsoft Excel Charting 2 11th Jul 2008 01:18 PM
show 3 sets of data per data point in a scatter plot =?Utf-8?B?TWFyaWU=?= Microsoft Excel Charting 6 19th May 2008 09:38 PM
Aligning rows of data from multiple data sets in columns e abor Microsoft Excel Discussion 1 29th Jun 2006 09:21 AM
compring two datasets Sylesh Nair Microsoft C# .NET 1 19th Aug 2003 01:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:35 PM.