Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare and delete in excel Please help in building a Vba in excel Excel Worksheet Functions 5 March 22nd 07 06:01 PM
Compare & Delete Centrol Excel Discussion (Misc queries) 2 September 26th 05 07:17 AM
Compare & Delete in Excel smittydotbat Excel Programming 7 October 19th 04 03:29 PM
Compare and delete or return value? shaun nieves[_4_] Excel Programming 3 May 26th 04 06:59 PM
Excel VBA - Help with a loop, compare, delete problem rippy Excel Programming 0 February 4th 04 03:38 PM


All times are GMT +1. The time now is 10:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"