#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 28
Default macro for dupes

Hi

I was searching for a macro to find dupes in s column and found the
following which working good also. But i want check for duplicates in the
first 4 charechers only which is a unique ID. can any one edit the same to
suite my requirement. a sample of data is given below:
0005TATA MOTORS-
0006TTK-PRESTIGE
0003ZEE-ESBE TIT
0007BAWA MASALE-
0005PLAYWIN-10
0004MPSTD-BISCOP
0635ZEE-DHOL-JAG
0032VANISH-SHINE
0010TATA MOTORS-
0004BSNL-RAP-30

the code i found is below:

Sub DupFinder()
Dim r As Range, t As Range
Set t = Selection
For Each r In t
v = r.Value
If Application.WorksheetFunction.CountIf(t, v) 1 Then
r.Interior.ColorIndex = 3
End If
Next
End Sub

thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default macro for dupes

You can do it with a formula. Note the dollar signs in front of the row.
A1:A10 is the range of data. Copy the frmula down the new column.

=SUMPRODUCT(--(LEFT(A$1:A$10,4)=LEFT(A1,4)))

"shaji" wrote:

Hi

I was searching for a macro to find dupes in s column and found the
following which working good also. But i want check for duplicates in the
first 4 charechers only which is a unique ID. can any one edit the same to
suite my requirement. a sample of data is given below:
0005TATA MOTORS-
0006TTK-PRESTIGE
0003ZEE-ESBE TIT
0007BAWA MASALE-
0005PLAYWIN-10
0004MPSTD-BISCOP
0635ZEE-DHOL-JAG
0032VANISH-SHINE
0010TATA MOTORS-
0004BSNL-RAP-30

the code i found is below:

Sub DupFinder()
Dim r As Range, t As Range
Set t = Selection
For Each r In t
v = r.Value
If Application.WorksheetFunction.CountIf(t, v) 1 Then
r.Interior.ColorIndex = 3
End If
Next
End Sub

thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default macro for dupes

Option Explicit
Sub DupFinder()
Dim r As Range
Dim t As Range
Dim V As String
Set t = Selection
For Each r In t.Cells
V = r.Value
If Application.WorksheetFunction.CountIf(t, Left(V, 4) & "*") 1 Then
r.Interior.ColorIndex = 3
End If
Next r
End Sub

=countif() is nice that it supports wildcards:

=countif(a1:a10,"asdf*")
will count the number of times you have entries that start with asdf in A1:A10.

shaji wrote:

Hi

I was searching for a macro to find dupes in s column and found the
following which working good also. But i want check for duplicates in the
first 4 charechers only which is a unique ID. can any one edit the same to
suite my requirement. a sample of data is given below:
0005TATA MOTORS-
0006TTK-PRESTIGE
0003ZEE-ESBE TIT
0007BAWA MASALE-
0005PLAYWIN-10
0004MPSTD-BISCOP
0635ZEE-DHOL-JAG
0032VANISH-SHINE
0010TATA MOTORS-
0004BSNL-RAP-30

the code i found is below:

Sub DupFinder()
Dim r As Range, t As Range
Set t = Selection
For Each r In t
v = r.Value
If Application.WorksheetFunction.CountIf(t, v) 1 Then
r.Interior.ColorIndex = 3
End If
Next
End Sub

thanks


--

Dave Peterson
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
Checking for Dupes TKnTexas Excel Discussion (Misc queries) 4 November 3rd 06 02:43 AM
How can I check for dupes in more than one column in excel? latwood Excel Worksheet Functions 2 October 23rd 06 08:42 PM
Summary Sheet For Identified Dupes Mhz New Users to Excel 6 July 14th 06 12:07 PM
Dynamic subtotals and eliminate dupes ttbbgg Excel Worksheet Functions 7 March 23rd 06 09:42 PM
How to check for dupes on 2 files, and ? about csv file ext PeterM Excel Discussion (Misc queries) 2 June 4th 05 10:51 PM


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

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"