![]() |
#1
|
|||
|
|||
![]()
I have a worksheet that contains many rows of data. In certain instances there may be several consecutive rows of data that have duplicate values in one column for example column A which is the id of students in column A and their costs in other columns, but each student may have the ID in different rows and so column A has duplicate values, I need a macro that can delete duplicates and retain one value, thanks in advance
![]() |
#2
|
||||
|
||||
![]()
Try something based on:
Code:
Sub DeleteDuplicateRows() Dim LRow As Long, i As Long, j As Long With ActiveSheet LRow = .Cells.SpecialCells(xlCellTypeLastCell).Row For i = LRow To 2 Step -1 For j = i - 1 To 1 Step -1 If .Range("A" & i).Value = .Range("A" & j).Value Then .Range("A" & j).EntireRow.Delete Next Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Tags |
delete duplicate, excel macro, filter |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
braddgood | Word VBA | 15 | 10-02-2015 01:54 PM |
![]() |
AlexanderJohnWilley | Word VBA | 7 | 11-08-2012 10:15 AM |
![]() |
elky1967 | Word VBA | 14 | 09-21-2012 05:27 AM |
![]() |
Steve_D | Excel | 2 | 08-24-2012 09:37 PM |
![]() |
ubns | Excel Programming | 2 | 08-14-2012 02:01 AM |