Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all, i have some code that i got from a search and it was apparantly
supplied by Tom Ogilvy. I need to understand it, as i have a lot of lines and i need to loop down deleteing lines with duplicate numbers in Column "A" & "D". However if Column "A" number is different and "D" is the same it must not delete !! Any help would be greatly appreciated.. Sub DeleteDuplicateRows() Dim RowNdx As Long Dim ColNum As Integer Dim rng As Range 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 If rng Is Nothing Then Set rng = Cells(RowNdx, ColNum) Else Set rng = Union(rng, Cells(RowNdx, ColNum)) End If End If Next RowNdx If Not rng Is Nothing Then rng.EntireRow.Delete End If End Sub Les Stout *** Sent via Developersdex http://www.developersdex.com *** |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete an entire row if two cells...... | Excel Discussion (Misc queries) | |||
how do i delete duplicate cells in the same row | Excel Discussion (Misc queries) | |||
How do I delete duplicate cells? | Excel Worksheet Functions | |||
How do I delete duplicate records from an entire Excel workbook? | Excel Discussion (Misc queries) | |||
Delete duplicate cells | Excel Programming |