Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 310
Default Remove Duplicates Based on more than one column

I have the follwoing data and need to remove the duplicates based on name
and date.
Example Data
Name Date
Jim Smith 7-1-07
Jim Smith 7-1-07
Jim Smith 7-1-07
Jim Smith 7-5-07
Jim Smith 7-5-07
Nancy Smith 7-5-07
Nancy Smith 7-5-07
Nancy Smith 7-5-07

this is the code I have now but is based on 1 column and 1 row.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 310
Default Remove Duplicates Based on more than one column

my code sorry

Sub RemoveDupes()
With Cells

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
rng.Select
End With

Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).EntireRow.Delete shift:=xlUp
End If
Next RowNdx
End Sub

"Michelle" wrote:

I have the follwoing data and need to remove the duplicates based on name
and date.
Example Data
Name Date
Jim Smith 7-1-07
Jim Smith 7-1-07
Jim Smith 7-1-07
Jim Smith 7-5-07
Jim Smith 7-5-07
Nancy Smith 7-5-07
Nancy Smith 7-5-07
Nancy Smith 7-5-07

this is the code I have now but is based on 1 column and 1 row.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Remove Duplicates Based on more than one column


Sub RemoveDupes_R1()
Dim rng As Range
Dim RowNdx As Long
Dim ColNum As Long
Dim strText As String
Dim strAbove As String

Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
ColNum = rng.Column
Application.ScreenUpdating = False

For RowNdx = rng(rng.Count).Row To rng.Row + 1 Step -1
strText = Cells(RowNdx, ColNum).Text & Cells(RowNdx, ColNum + 1).Text
strAbove = Cells(RowNdx - 1, ColNum).Text & Cells(RowNdx - 1, ColNum + 1).Text
If strText = strAbove Then Rows(RowNdx).Delete shift:=xlUp
Next 'RowNdx

Application.ScreenUpdating = True
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Michelle"
wrote in message
my code sorry

Sub RemoveDupes()
With Cells

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
rng.Select
End With

Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).EntireRow.Delete shift:=xlUp
End If
Next RowNdx
End Sub

"Michelle" wrote:

I have the follwoing data and need to remove the duplicates based on name
and date.
Example Data
Name Date
Jim Smith 7-1-07
Jim Smith 7-1-07
Jim Smith 7-1-07
Jim Smith 7-5-07
Jim Smith 7-5-07
Nancy Smith 7-5-07
Nancy Smith 7-5-07
Nancy Smith 7-5-07

this is the code I have now but is based on 1 column and 1 row.

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
Filter duplicates based on criteria / column values phillr Excel Discussion (Misc queries) 0 April 9th 10 09:13 PM
Remove Duplicates Joe Excel Worksheet Functions 2 February 13th 09 11:58 PM
How to remove duplicates? Lakewoodsale Excel Discussion (Misc queries) 2 January 25th 08 10:31 PM
Coloring duplicates based on values in a column. Josh Excel Programming 6 June 4th 07 07:37 PM
remove duplicates using vba jeff quigley Excel Programming 2 June 14th 05 07:19 PM


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