Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Highlighting Duplicates in a List

I'm using the following code to highlight duplicate data
contained in two lists. Unfortunately both lists are huge
so it's taking the macro a long time to run and is using a
lot of memory. Would anyone have any advice on how the
code could be modified to run more efficiently? My
thought was that maybe the data could be loaded into an
array but I am not yet proficient with how to handle VBA
arrays. Thanks for your help.

Sub FindDuplicates()
Application.ScreenUpdating = False
Dim Rng1 As Range
Dim Rng2 As Range
Dim x As Variant
Dim y As Variant
Set Rng1 = Range("B7:B15000")
Set Rng2 = Range("C7:C15000")

For Each x In Rng1
For Each y In Rng2
If x = y Then
x.Interior.ColorIndex = 6
y.Interior.ColorIndex = 6
End If
Next y
Next x
Application.ScreenUpdating = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Highlighting Duplicates in a List

Have you tried conditional formatting instead?

Format--Conditional Format--Formula is:
=IF(COUNTIF($C$7:$C$15000, B7)1,TRUE,FALSE)

John Mansfield wrote:
I'm using the following code to highlight duplicate data
contained in two lists. Unfortunately both lists are huge
so it's taking the macro a long time to run and is using a
lot of memory. Would anyone have any advice on how the
code could be modified to run more efficiently? My
thought was that maybe the data could be loaded into an
array but I am not yet proficient with how to handle VBA
arrays. Thanks for your help.

Sub FindDuplicates()
Application.ScreenUpdating = False
Dim Rng1 As Range
Dim Rng2 As Range
Dim x As Variant
Dim y As Variant
Set Rng1 = Range("B7:B15000")
Set Rng2 = Range("C7:C15000")

For Each x In Rng1
For Each y In Rng2
If x = y Then
x.Interior.ColorIndex = 6
y.Interior.ColorIndex = 6
End If
Next y
Next x
Application.ScreenUpdating = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Highlighting Duplicates in a List

Make that 0 since you are looking for duplicates in different columns.

JWolf wrote:

Have you tried conditional formatting instead?

Format--Conditional Format--Formula is:
=IF(COUNTIF($C$7:$C$15000, B7)1,TRUE,FALSE)

John Mansfield wrote:

I'm using the following code to highlight duplicate data contained in
two lists. Unfortunately both lists are huge so it's taking the macro
a long time to run and is using a lot of memory. Would anyone have
any advice on how the code could be modified to run more efficiently?
My thought was that maybe the data could be loaded into an array but I
am not yet proficient with how to handle VBA arrays. Thanks for your
help.
Sub FindDuplicates()
Application.ScreenUpdating = False
Dim Rng1 As Range
Dim Rng2 As Range
Dim x As Variant
Dim y As Variant
Set Rng1 = Range("B7:B15000")
Set Rng2 = Range("C7:C15000")

For Each x In Rng1
For Each y In Rng2
If x = y Then
x.Interior.ColorIndex = 6
y.Interior.ColorIndex = 6
End If
Next y
Next x
Application.ScreenUpdating = True
End Sub

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
highlighting duplicates...except it doesn't boombox Excel Discussion (Misc queries) 2 September 17th 09 11:33 PM
Need Help with Highlighting duplicates across several sheets vote4pedro Excel Worksheet Functions 1 September 1st 08 10:05 PM
highlighting duplicates alex Excel Worksheet Functions 2 February 1st 06 05:41 PM
Help with Highlighting all duplicates in a row Jimv Excel Discussion (Misc queries) 4 April 21st 05 07:12 PM
Highlighting Duplicates Sam New Users to Excel 6 March 18th 05 07:27 PM


All times are GMT +1. The time now is 12:55 PM.

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

About Us

"It's about Microsoft Excel"