LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Deleting Rows with data duplicated in 2 columns

Hi there,

I am trying, with no luck, to create a VBA macro in Excel that will
delete rows with data duplicated in 2 columns. Column A has ID
numbers and Column B has Dates. I need to delete rows that have
duplicate ID No. AND Date and leave the other rows on the worksheet.

I have tried Chip Pearson's code which works well however it doesn't
allow for the dates in column B so it considered the latest date to be
the record to leave and deletes the rest.

Sub DeleteTheOldies()
Dim RowNdx As Long
For RowNdx = Range("A1").End(xlDown).Row To 2 Step -1
If Cells(RowNdx, "H").Value = Cells(RowNdx - 1, "H").Value Then
If Cells(RowNdx, "I").Value <= Cells(RowNdx - 1, "I").Value
Then
Rows(RowNdx).Delete
Else
Rows(RowNdx - 1).Delete
End If
End If
Next RowNdx
End Sub

Example - Befo

ID No. Date
123456 1-2-07
123456 1-2-07
123456 2-2-07
123456 2-2-07
123456 3-2-07
123456 3-2-07

Example - After:

ID No. Date
123456 1-2-07
123456 2-2-07
123456 3-2-07

Any advice will be greatly appreciate. Many thanks.

 
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 cells in a list via advanced autofilter? petevang Excel Discussion (Misc queries) 1 December 7th 05 03:54 PM
Charts should not be resized when deleting rows/columns. BobM Charts and Charting in Excel 1 February 11th 05 07:39 AM
Disable Adding & Deleting Rows/Columns Playa Excel Discussion (Misc queries) 1 February 3rd 05 03:42 PM
Deleting excess rows and columns abbyzmom New Users to Excel 2 January 18th 05 05:11 PM
Disable Adding or Deleting Rows and Columns Playa Excel Discussion (Misc queries) 1 January 10th 05 10:23 PM


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