LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Identifying Duplicate Values Code Modification Help

In VBA code I would like to check a colum of values for uniqueness.
Basically, I want to loop through the column and write duplicate instances to
an error file.

From the table example listed below:

Row Num column
1 123
2 124
3 123
4 3
5 123
6 456
7 456
8 sdfg
9 12345
10 sdfg
11 sdfg

My result set should look like:

Row Error Description
1 123 duplicate record
3 123 duplicate record
5 123 duplicate record
6 456 duplicate record
7 456 duplicate record
8 sdfg duplicate record
10 sdfg duplicate record
11 sdfg duplicate record

However, the result set I'm getting is only searching for the first value.

1 123 duplicate record
3 123 duplicate record
5 123 duplicate record

The code I'm using is listed below:

Public Sub a000000000000dupsearchrev()

Dim dupval As String
Dim curval As String
Dim rownum As String
Dim varMstrSrch()
Dim searchval As String
Dim i As Integer
Dim ubnd As Long

Sheets("master").Activate
varMstrSrch() = Range("b2:b17") '65536") ' Read it in
Range("b2").Select
Do Until IsEmpty(ActiveCell)
dupval = ActiveCell
searchval = dupval 'this is the value we are seeking
For i = LBound(varMstrSrch()) To UBound(varMstrSrch())
ubnd = UBound(varMstrSrch())
If varMstrSrch(i, 1) = searchval Then
curval = ActiveCell
rownum = ActiveCell.Offset(0, -1)
Sheets("DataEntry-Errors").Activate
ActiveCell = rownum
ActiveCell.Offset(0, 1) = curval
ActiveCell.Offset(0, 2) = "duplicate record"
ActiveCell.Offset(1, 0).Select
Sheets("master").Activate
End If
ActiveCell.Offset(1, 0).Select
Next i
'ActiveCell.Offset(1, 0).Select
Loop
End Sub

If I remove the comment I get duplicate search results. Any help anyone can
offer would be greatly appreciated. Thanks in advance.

AxLa


 
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
Identifying Duplicate data between 2 columns Naja Excel Worksheet Functions 3 July 7th 09 06:16 AM
Identifying duplicate data KKD Excel Discussion (Misc queries) 2 May 28th 09 12:39 AM
Identifying duplicate values in a range Paul Excel Discussion (Misc queries) 1 May 3rd 09 10:31 PM
Identifying duplicate entries japc90 Excel Discussion (Misc queries) 5 February 1st 08 05:36 PM
Identifying duplicate rows TBA Excel Discussion (Misc queries) 2 June 15th 07 09:38 AM


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

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"