Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Compare & Delete in Excel
Dave, What you gave me works! I have had only one issue and it was when I had something duplicate i Col A, then it would delete all of Col B. But that is my problem, not yours. Thanks a bunch... Dave Peterson Wrote: How about: Option Explicit Sub testme01() Dim FirstRow As Long Dim LastRow As Long Dim iRow As Long Dim res As Variant With ActiveSheet FirstRow = 1 'no headers in row 1??? LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row For iRow = LastRow To FirstRow Step -1 res = Application.Match(.Cells(iRow, "B").Value, .Range("a:a"), 0) If IsError(res) Then 'keep it--it's unique Else .Cells(res, "B").Delete shift:=xlShiftUp End If Next iRow End With End Sub smittydotbat wrote: I am new to the excel programming with VB and I need some help... I have an excel workbook with one sheet. In one column I have a lis of names. On another column I have another list of names. What I am trying to accomplish is that when a button click event is invoked, I would like the cells in the first column to be compared against the other column. When it does this compare it will stri out the duplicates in column two (which are also in column one) an leave what's left. Scenario: *Before the compare* Column A Column B x x xy xyy xyz xyz yzx yzx *After the Compare* Column A Column B x xyy xy xyz yzx If anyone can help me with this I would greatly be appreciative. -- smittydotbat ------------------------------------------------------------------------ smittydotbat's Profile http://www.excelforum.com/member.php...o&userid=15232 View this thread http://www.excelforum.com/showthread...hreadid=268648 -- Dave Peterson -- smittydotba ----------------------------------------------------------------------- smittydotbat's Profile: http://www.excelforum.com/member.php...fo&userid=1523 View this thread: http://www.excelforum.com/showthread.php?threadid=26864 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Compare and delete in excel | Excel Worksheet Functions | |||
Compare & Delete | Excel Discussion (Misc queries) | |||
Compare & Delete in Excel | Excel Programming | |||
Compare and delete or return value? | Excel Programming | |||
Excel VBA - Help with a loop, compare, delete problem | Excel Programming |