Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Find duplicate entries that have trailing digit that may change.

I found a macro to highlight duplicates and it is excellent! I need to
take it a step further and was hoping you could help.

This is what I need to do.

I need to find and highlight a number with mixed digits and characters such
as this example. 12345678ABCD0001. Your current version does that. Here
is the problem I have. I need not only find exact duplicates but also need
to find duplicates that may have a trailing such as 1,2,3,4,5,6 etc. and
still will pick it up as duplicate as this is a release number. Now, I
figure there are 2 ways you could do this but I am not sure. One, is to
drop the last digit then search for all duplicates. Two, to search on the
1st 8 digits only.

So, do you have any idea how to do this based on the current duplicate/find
macro below?

Sub GetDuplicates()
'
Range("A1:A100").Select
For Each Rng In Selection.Cells
If Application.WorksheetFunction.CountIf( _
Selection, Rng) 1 Then
Rng.Interior.ColorIndex = 6 'yellow
Else
Rng.Interior.ColorIndex = 2 'white
End If
Next Rng


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default Find duplicate entries that have trailing digit that may change.

Try this:

Sub GetDuplicates()
'
Dim myNewRange
Dim Rng As Range
Range("A1:A100").Select
Set myNewRange = Nothing
For Each Rng In Selection.Cells
If Application.WorksheetFunction.CountIf( _
Selection, Rng) 1 Then
Rng.Interior.ColorIndex = 6 'yellow
Else
Rng.Interior.ColorIndex = 2 'white
End If

'Defines a new range with one less character
If myNewRange = Nothing Then
myNewRange = Left(Rng, Len(Rng) - 1)
Else
myNewRange = Union(myNewRange, Left(Rng, Len(Rng) - 1))
End If
Next Rng

'Checks for duplicates with range that's 1 character less
For Each Rng In myNewRange
If Application.WorksheetFunction.CountIf( _
myNewRange, Rng) 1 Then
Rng.Interior.ColorIndex = 6 'yellow
Else
'Rng.Interior.ColorIndex = 2 'white I'm not sure you need this.
End If

Next Rng


End Sub


HTH,
Barb Reinhardt



"DENNIS SHEROW" wrote:

I found a macro to highlight duplicates and it is excellent! I need to
take it a step further and was hoping you could help.

This is what I need to do.

I need to find and highlight a number with mixed digits and characters such
as this example. 12345678ABCD0001. Your current version does that. Here
is the problem I have. I need not only find exact duplicates but also need
to find duplicates that may have a trailing such as 1,2,3,4,5,6 etc. and
still will pick it up as duplicate as this is a release number. Now, I
figure there are 2 ways you could do this but I am not sure. One, is to
drop the last digit then search for all duplicates. Two, to search on the
1st 8 digits only.

So, do you have any idea how to do this based on the current duplicate/find
macro below?

Sub GetDuplicates()
'
Range("A1:A100").Select
For Each Rng In Selection.Cells
If Application.WorksheetFunction.CountIf( _
Selection, Rng) 1 Then
Rng.Interior.ColorIndex = 6 'yellow
Else
Rng.Interior.ColorIndex = 2 'white
End If
Next Rng



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
Find and Delete Duplicate entries Barry Walker Excel Discussion (Misc queries) 10 July 9th 07 06:02 PM
2 workbooks - how do I find duplicate entries by comparing the two queen on Excel Discussion (Misc queries) 2 September 20th 05 11:12 AM
How do I find duplicate entries in Excel cher Excel Discussion (Misc queries) 2 June 23rd 05 06:29 PM
find duplicate entries and delete them? Agnitoood Excel Worksheet Functions 1 February 28th 05 10:53 AM
Find duplicate entries kharrison Excel Discussion (Misc queries) 3 February 24th 05 11:19 PM


All times are GMT +1. The time now is 01:43 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"