Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2014, 06:12 AM
Noah14 Noah14 is offline Deleting rows with partially redundant data Mac OS X Deleting rows with partially redundant data Office for Mac 2011
Novice
Deleting rows with partially redundant data
 
Join Date: Sep 2014
Posts: 1
Noah14 is on a distinguished road
Default Deleting rows with partially redundant data

Dear pros,

I have got a table with a couple thousand of line entries and a number of columns. One of the columns contains document names (one per line, example pls. see below). For purposes of further data processing, I consider all document names with the same 21 leading digits (so everything up to and including the last dash) as identical. I am looking for a vba code that deletes identical / redundant lines and only keeps the lines with document name ending on 01. In the example below, lines 1 and 4 are to be kept and 2,3,5,6 deleted.



Thanks in advance!
Noah

322-215000-02-1-1-PR-01
322-215000-02-1-1-PR-02
322-215000-02-1-1-PR-03
322-215000-02-1-2-PR-01
322-215000-02-1-2-PR-02
322-215000-02-1-2-PR-03
Reply With Quote
  #2  
Old 09-19-2014, 11:46 PM
gmayor's Avatar
gmayor gmayor is offline Deleting rows with partially redundant data Windows 7 64bit Deleting rows with partially redundant data Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Assuming Mac VBA is similar to PC VBA then the following should work. The code assumes column A contains the document names in question

Code:
Sub RemoveDuplicates()
Dim LastRow As Long
Dim i As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = LastRow To 2 Step -1
    If Left(Cells(i, 1), 18) = Left(Cells(i - 1, 1), 18) Then
        Rows(i).Delete Shift:=xlUp
    End If
Next i
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting rows & pushing them up causing issues ep2002 Excel 2 08-29-2014 02:09 AM
Deleting rows with partially redundant data Macro for Column to Rows Data brunssl2 Excel Programming 3 04-28-2014 07:07 AM
Deleting rows with partially redundant data Deleting rows with specific criteria joflow21 Excel 9 11-22-2013 12:10 PM
Outlook 2010 & Redundant Files Cleanup goombarok Outlook 0 03-09-2012 08:04 AM
Concatenated data in subsequent rows doorsgirl Excel 4 09-15-2011 10:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:45 PM.


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