Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Fastest way for comparing columns?

Hi Group,

I am using Chip Pearon's excellent formula for comparing
values in various cols, i.e Col B & Col A and vice versa.
It works well but it has become very, very, very slow due
to the size of the ranges I'm working with (10,000+)
rows. Is there a faster method available (VBA?) to allow
me to produce similiar results
? Here is Chip's formula.

=IF(INDIRECT(ADDRESS(ROW(),COLUMN(Range2)))="","", IF
(COUNTIF(Range1,INDIRECT(ADDRESS(ROW(),COLUMN(Rang e2),4)))
=0,INDIRECT(ADDRESS(ROW(),COLUMN(Range2),4)),""))

Ideally I would like to produce the results...
if in Col A but not in Col B put in Col C
if in Col B but not in Col A put in Col D
If duplicates put in Col E

I amusing Excel 2000 on pentium 4.

Regards

Tony



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Fastest way for comparing columns?

Hi,

I assume that the two columns are numbers - well my
example does anyway:

Other things to note - you can test for the last row, and
place that into the code instead of it being hard coded in
this example.

I used randbetween for column A and B to generate numbers
between 1 and 100 for 10,000 rows to see how long it took -
answers were populated within 8 seconds.

I am sure the code could be improved.......

Option Explicit

Sub try_this()
Dim intrwindex As Integer
Dim intcolindex As Integer
Dim int_cola As Integer
Dim int_colb As Integer

intcolindex = 1

For intrwindex = 1 To 10000
int_cola = Cells(intrwindex, intcolindex).Value
int_colb = Cells(intrwindex, intcolindex).Offset(0,
1).Value


If str_cola < str_colb Then
Cells(intrwindex, intcolindex).Offset(0, 2).Value =
int_cola
Cells(intrwindex, intcolindex).Offset(0, 3).Value =
int_colb

Else
Cells(intrwindex, intcolindex).Offset(0, 4).Value =
int_cola
End If

Next intrwindex

End Sub

HTH



-----Original Message-----
Hi Group,

I am using Chip Pearon's excellent formula for comparing
values in various cols, i.e Col B & Col A and vice

versa.
It works well but it has become very, very, very slow due
to the size of the ranges I'm working with (10,000+)
rows. Is there a faster method available (VBA?) to allow
me to produce similiar results
? Here is Chip's formula.

=IF(INDIRECT(ADDRESS(ROW(),COLUMN(Range2)))="","" ,IF
(COUNTIF(Range1,INDIRECT(ADDRESS(ROW(),COLUMN(Ran ge2),4)))
=0,INDIRECT(ADDRESS(ROW(),COLUMN(Range2),4)),"" ))

Ideally I would like to produce the results...
if in Col A but not in Col B put in Col C
if in Col B but not in Col A put in Col D
If duplicates put in Col E

I amusing Excel 2000 on pentium 4.

Regards

Tony



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Fastest way for comparing columns?

Wow, that IS fast Alan. Many thanks indeed
Mike - will look at array formulas as suggested.

T.
-----Original Message-----
Hi,

I assume that the two columns are numbers - well my
example does anyway:

Other things to note - you can test for the last row, and
place that into the code instead of it being hard coded

in
this example.

I used randbetween for column A and B to generate numbers
between 1 and 100 for 10,000 rows to see how long it

took -
answers were populated within 8 seconds.

I am sure the code could be improved.......

Option Explicit

Sub try_this()
Dim intrwindex As Integer
Dim intcolindex As Integer
Dim int_cola As Integer
Dim int_colb As Integer

intcolindex = 1

For intrwindex = 1 To 10000
int_cola = Cells(intrwindex, intcolindex).Value
int_colb = Cells(intrwindex, intcolindex).Offset(0,
1).Value


If str_cola < str_colb Then
Cells(intrwindex, intcolindex).Offset(0, 2).Value =
int_cola
Cells(intrwindex, intcolindex).Offset(0, 3).Value =
int_colb

Else
Cells(intrwindex, intcolindex).Offset(0, 4).Value =
int_cola
End If

Next intrwindex

End Sub

HTH



-----Original Message-----
Hi Group,

I am using Chip Pearon's excellent formula for comparing
values in various cols, i.e Col B & Col A and vice

versa.
It works well but it has become very, very, very slow

due
to the size of the ranges I'm working with (10,000+)
rows. Is there a faster method available (VBA?) to

allow
me to produce similiar results
? Here is Chip's formula.

=IF(INDIRECT(ADDRESS(ROW(),COLUMN(Range2)))=""," ",IF
(COUNTIF(Range1,INDIRECT(ADDRESS(ROW(),COLUMN

(Range2),4)))
=0,INDIRECT(ADDRESS(ROW(),COLUMN(Range2),4)),"") )

Ideally I would like to produce the results...
if in Col A but not in Col B put in Col C
if in Col B but not in Col A put in Col D
If duplicates put in Col E

I amusing Excel 2000 on pentium 4.

Regards

Tony



.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Fastest way for comparing columns?

Matching cells are always side by side?

--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
Wow, that IS fast Alan. Many thanks indeed
Mike - will look at array formulas as suggested.

T.
-----Original Message-----
Hi,

I assume that the two columns are numbers - well my
example does anyway:

Other things to note - you can test for the last row, and
place that into the code instead of it being hard coded

in
this example.

I used randbetween for column A and B to generate numbers
between 1 and 100 for 10,000 rows to see how long it

took -
answers were populated within 8 seconds.

I am sure the code could be improved.......

Option Explicit

Sub try_this()
Dim intrwindex As Integer
Dim intcolindex As Integer
Dim int_cola As Integer
Dim int_colb As Integer

intcolindex = 1

For intrwindex = 1 To 10000
int_cola = Cells(intrwindex, intcolindex).Value
int_colb = Cells(intrwindex, intcolindex).Offset(0,
1).Value


If str_cola < str_colb Then
Cells(intrwindex, intcolindex).Offset(0, 2).Value =
int_cola
Cells(intrwindex, intcolindex).Offset(0, 3).Value =
int_colb

Else
Cells(intrwindex, intcolindex).Offset(0, 4).Value =
int_cola
End If

Next intrwindex

End Sub

HTH



-----Original Message-----
Hi Group,

I am using Chip Pearon's excellent formula for comparing
values in various cols, i.e Col B & Col A and vice

versa.
It works well but it has become very, very, very slow

due
to the size of the ranges I'm working with (10,000+)
rows. Is there a faster method available (VBA?) to

allow
me to produce similiar results
? Here is Chip's formula.

=IF(INDIRECT(ADDRESS(ROW(),COLUMN(Range2)))=""," ",IF
(COUNTIF(Range1,INDIRECT(ADDRESS(ROW(),COLUMN

(Range2),4)))
=0,INDIRECT(ADDRESS(ROW(),COLUMN(Range2),4)),"") )

Ideally I would like to produce the results...
if in Col A but not in Col B put in Col C
if in Col B but not in Col A put in Col D
If duplicates put in Col E

I amusing Excel 2000 on pentium 4.

Regards

Tony



.

.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Fastest way for comparing columns?

Typically an Array Formula is the fastest way to compare 2 lists. Coupled
with an IF statement in column C, compare A to B, if result =0 then = the
value in A, if not then "". In column D do the same to compare B to A. Now
an IF statement in column E to to see if the cell in column C or D is "". If
C is "" then the value from A, If D is "" then value from B, If neither is
"", then "".

Chip's website can help with the array formula.

Mike F

"Tony" wrote in message
...
Hi Group,

I am using Chip Pearon's excellent formula for comparing
values in various cols, i.e Col B & Col A and vice versa.
It works well but it has become very, very, very slow due
to the size of the ranges I'm working with (10,000+)
rows. Is there a faster method available (VBA?) to allow
me to produce similiar results
? Here is Chip's formula.

=IF(INDIRECT(ADDRESS(ROW(),COLUMN(Range2)))="","", IF
(COUNTIF(Range1,INDIRECT(ADDRESS(ROW(),COLUMN(Rang e2),4)))
=0,INDIRECT(ADDRESS(ROW(),COLUMN(Range2),4)),""))

Ideally I would like to produce the results...
if in Col A but not in Col B put in Col C
if in Col B but not in Col A put in Col D
If duplicates put in Col E

I amusing Excel 2000 on pentium 4.

Regards

Tony







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
comparing two columns JoeM[_3_] Excel Worksheet Functions 5 May 1st 09 07:12 PM
Comparing Columns to each other Sung Excel Discussion (Misc queries) 2 May 25th 07 08:17 PM
Comparing two columns of information with 2 new columns of informa cbuck Excel Discussion (Misc queries) 1 January 16th 07 09:49 PM
comparing columns dfeld71 Excel Discussion (Misc queries) 2 July 14th 05 11:00 AM
Fastest way to do this? Abu Ali Excel Programming 4 January 12th 04 09:24 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"