Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Deleting duplicated rows based on data in two columns

I have a range of data in cells A1:K1000 and some of the row data in that
range has been partially duplicated. What I would like to do is to delete
the duplicated row if the cell values in column A are the same as well as the
data in Column E.

For example:
If cell A1 (Smith) and A2 (Smith) are the same and cells E1 (Microsoft) and
E2 (Microsoft) are the same, delete row 2. However If cell A1 (Smith) and A2
(Smith) are the same and cells E1 (Microsoft) and E2 (Apple) are different,
then this is not a duplicate so it should not be deleted.

Any assistance would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Deleting duplicated rows based on data in two columns

Try this:

========
Sub DeleteDupes()
'JBeaucaire (11/16/2009)
Dim LR As Long, i As Long
Application.ScreenUpdating = False

LR = Range("A" & Rows.Count).End(xlUp).Row

For i = LR To 2 Step -1
If Cells(i, "A") = Cells(i - 1, "A") And _
Cells(i, "E") = Cells(i - 1, "E") Then _
Rows(i).Delete xlShiftUp
End If
Next i

Application.ScreenUpdating = True
End Sub
========

Does that help?

--
"Actually, I *am* a rocket scientist." -- JB
(www.MadRocketScientist.com)

Your feedback is appreciated, click YES if this post helped you.


"Monk" wrote:

I have a range of data in cells A1:K1000 and some of the row data in that
range has been partially duplicated. What I would like to do is to delete
the duplicated row if the cell values in column A are the same as well as the
data in Column E.

For example:
If cell A1 (Smith) and A2 (Smith) are the same and cells E1 (Microsoft) and
E2 (Microsoft) are the same, delete row 2. However If cell A1 (Smith) and A2
(Smith) are the same and cells E1 (Microsoft) and E2 (Apple) are different,
then this is not a duplicate so it should not be deleted.

Any assistance would be appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
om om is offline
external usenet poster
 
Posts: 18
Default Deleting duplicated rows based on data in two columns

Hi

Easier approach to do this - -

DataFilterAdvanced Filter --select Unique records only

This will filter the unique records.. then u can select copy to another
location

Regards
Om

"JBeaucaire" wrote:

Try this:

========
Sub DeleteDupes()
'JBeaucaire (11/16/2009)
Dim LR As Long, i As Long
Application.ScreenUpdating = False

LR = Range("A" & Rows.Count).End(xlUp).Row

For i = LR To 2 Step -1
If Cells(i, "A") = Cells(i - 1, "A") And _
Cells(i, "E") = Cells(i - 1, "E") Then _
Rows(i).Delete xlShiftUp
End If
Next i

Application.ScreenUpdating = True
End Sub
========

Does that help?

--
"Actually, I *am* a rocket scientist." -- JB
(www.MadRocketScientist.com)

Your feedback is appreciated, click YES if this post helped you.


"Monk" wrote:

I have a range of data in cells A1:K1000 and some of the row data in that
range has been partially duplicated. What I would like to do is to delete
the duplicated row if the cell values in column A are the same as well as the
data in Column E.

For example:
If cell A1 (Smith) and A2 (Smith) are the same and cells E1 (Microsoft) and
E2 (Microsoft) are the same, delete row 2. However If cell A1 (Smith) and A2
(Smith) are the same and cells E1 (Microsoft) and E2 (Apple) are different,
then this is not a duplicate so it should not be deleted.

Any assistance would be appreciated.

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
Deleting Duplicated Data by Cell Fleone Excel Discussion (Misc queries) 2 January 26th 10 06:29 PM
Compare multiple rows for duplicated values in individual columns LyndonMBA Excel Worksheet Functions 1 February 21st 09 11:34 AM
Deleting rows based on data NOT meeting criteria --working macro here, just need help with tweaking Zarlot531 Excel Programming 4 April 29th 07 12:40 AM
Deleting Rows with data duplicated in 2 columns [email protected] Excel Worksheet Functions 7 April 10th 07 07:18 PM
Comparing columns and deleting rows based on criteria ALATL Excel Programming 3 November 6th 06 04:34 PM


All times are GMT +1. The time now is 02:33 PM.

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"