Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2014, 11:00 AM
expert4knowledge expert4knowledge is offline Macro to Delete Duplicate Rows and Retain Unique Value Windows 7 32bit Macro to Delete Duplicate Rows and Retain Unique Value Office 2010 32bit
Advanced Beginner
Macro to Delete Duplicate Rows and Retain Unique Value
 
Join Date: Apr 2012
Posts: 59
expert4knowledge is on a distinguished road
Default Macro to Delete Duplicate Rows and Retain Unique Value

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
Reply With Quote
  #2  
Old 02-17-2014, 08:02 PM
macropod's Avatar
macropod macropod is offline Macro to Delete Duplicate Rows and Retain Unique Value Windows 7 32bit Macro to Delete Duplicate Rows and Retain Unique Value Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Tags
delete duplicate, excel macro, filter



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Delete Duplicate Rows and Retain Unique Value Macro to delete all empty rows from all tables braddgood Word VBA 15 10-02-2015 01:54 PM
Macro to Delete Duplicate Rows and Retain Unique Value Word Macro to find and delete rows that contain adjacent cells containing "." AlexanderJohnWilley Word VBA 7 11-08-2012 10:15 AM
Macro to Delete Duplicate Rows and Retain Unique Value Delete all rows but the last. elky1967 Word VBA 14 09-21-2012 05:27 AM
Macro to Delete Duplicate Rows and Retain Unique Value Macro to conditionally delete rows Steve_D Excel 2 08-24-2012 09:37 PM
Macro to Delete Duplicate Rows and Retain Unique Value Macro to delete rows with all empty cells ubns Excel Programming 2 08-14-2012 02:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:53 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft