Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi David,
Your code, which was originally supplied by Chip Pearson, does delete rows. It uses the active column to determine duplication. --- Regards, Norman "david shapiro" wrote in message ... Norman, Thanks for the suggestion, it`s good to know about that page. I checked this page, and I`d like to put this code except that I`d like to delete duplicate rows which are identical. I think this code (copied below) duplicates on the basis of selected columns. Is there some way to alter this code so that it deletes duplicate rows? David Public Sub DeleteDuplicateRows() ' ' This macro deletes duplicate rows in the selection. Duplicates are ' counted in the COLUMN of the active cell. Dim Col As Integer Dim r As Long Dim C As Range Dim N As Long Dim V As Variant Dim Rng As Range On Error GoTo EndMacro Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Col = ActiveCell.Column If Selection.Rows.Count 1 Then Set Rng = Selection Else Set Rng = ActiveSheet.UsedRange.Rows End If N = 0 For r = Rng.Rows.Count To 1 Step -1 V = Rng.Cells(r, 1).Value If Application.WorksheetFunction.CountIf(Rng.Columns( 1), V) 1 Then Rng.Rows(r).EntireRow.Delete N = N + 1 End If Next r EndMacro: Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic End Sub *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting Duplications | Excel Discussion (Misc queries) | |||
remove duplications | Excel Discussion (Misc queries) | |||
VBA Code to remove VBA | Excel Programming | |||
Use VB code to remove code in sheet1 | Excel Programming | |||
Remove VBA code | Excel Programming |