Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Finding Duplicate Rows (Macro)

Hi,

I have a table with several rows and columns of information. I will
continue to add new information new rows and I want to make sure that I never
have duplicated a row.

So here is a simple example:

A B C
1 i 1 k

2 r 3 n

3 a 2 f

4 a 1 f


I want to be able to add another row of information and if the array in that
row from columns a to c matches an array I already have I want to be notified
and it would also be nice to know which array I am duplicating.

I would like to accomplish the task above, but using the VBA tool (macros).
Ideally I would get the Item Number (located in the first column) of the
array Im duplicating in a message box.

Any help would be greatly appreciated!

Regards,

--
Edwin
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Finding Duplicate Rows (Macro)

Here's a simplistic macro that might get you started. After inputting your
data, and having selected a cell in the row you want to check, you could run
this.

Sub FindDuplicate()
xEnd = ActiveCell.Row

For i = 1 To xEnd - 1
If Cells(i, 1).Value = Cells(xEnd, 1) Then
If Cells(i, 2).Value = Cells(xEnd, 2) Then
If Cells(i, 3).Value = Cells(xEnd, 3) Then
MsgBox "Row " & i & " contains duplicate entry.", vbOKOnly, _
"Duplicate Found"
Exit Sub
End If
End If
End If
Next
MsgBox "No duplicate found", vbOKOnly, "No Duplicates"
End Sub

--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Edwin" wrote:

Hi,

I have a table with several rows and columns of information. I will
continue to add new information new rows and I want to make sure that I never
have duplicated a row.

So here is a simple example:

A B C
1 i 1 k

2 r 3 n

3 a 2 f

4 a 1 f


I want to be able to add another row of information and if the array in that
row from columns a to c matches an array I already have I want to be notified
and it would also be nice to know which array I am duplicating.

I would like to accomplish the task above, but using the VBA tool (macros).
Ideally I would get the Item Number (located in the first column) of the
array Im duplicating in a message box.

Any help would be greatly appreciated!

Regards,

--
Edwin

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Finding Duplicate Rows (Macro)

Thanks Luke!! This is a great start!

Do you think it is possible to obtain the location of more than one
duplicated row in the table? Maybe using a loop or something like that??

--
Edwin


"Luke M" wrote:

Here's a simplistic macro that might get you started. After inputting your
data, and having selected a cell in the row you want to check, you could run
this.

Sub FindDuplicate()
xEnd = ActiveCell.Row

For i = 1 To xEnd - 1
If Cells(i, 1).Value = Cells(xEnd, 1) Then
If Cells(i, 2).Value = Cells(xEnd, 2) Then
If Cells(i, 3).Value = Cells(xEnd, 3) Then
MsgBox "Row " & i & " contains duplicate entry.", vbOKOnly, _
"Duplicate Found"
Exit Sub
End If
End If
End If
Next
MsgBox "No duplicate found", vbOKOnly, "No Duplicates"
End Sub

--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Edwin" wrote:

Hi,

I have a table with several rows and columns of information. I will
continue to add new information new rows and I want to make sure that I never
have duplicated a row.

So here is a simple example:

A B C
1 i 1 k

2 r 3 n

3 a 2 f

4 a 1 f


I want to be able to add another row of information and if the array in that
row from columns a to c matches an array I already have I want to be notified
and it would also be nice to know which array I am duplicating.

I would like to accomplish the task above, but using the VBA tool (macros).
Ideally I would get the Item Number (located in the first column) of the
array Im duplicating in a message box.

Any help would be greatly appreciated!

Regards,

--
Edwin

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
Finding Duplicate Rows Secret Squirrel Excel Discussion (Misc queries) 1 April 8th 07 05:49 AM
Delete Duplicate Rows Macro Question elfmajesty Excel Discussion (Misc queries) 1 June 17th 06 01:12 AM
finding duplicate rows [email protected] Excel Worksheet Functions 1 June 16th 06 01:31 PM
Macro - to copy duplicate rows to another sheet [email protected] Excel Worksheet Functions 2 April 19th 05 01:53 AM
finding duplicate then copying macro.. Michael A Excel Discussion (Misc queries) 5 March 8th 05 03:26 AM


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