Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks!
Works like a charm! "Tom Ogilvy" wrote in message ... My mistake - there is a typo in Dave's code. Here is a revision: 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(iRow, "B").Delete shift:=xlShiftUp End If Next iRow End With End Sub this line .Cells(iRow, "B").Delete shift:=xlShiftUp originally was .Cells(res, "B").Delete shift:=xlShiftUp |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Compare and delete in excel | Excel Worksheet Functions | |||
Compare & Delete | Excel Discussion (Misc queries) | |||
Compare and delete cell? | Excel Programming | |||
Compare and delete or return value? | Excel Programming | |||
Excel VBA - Help with a loop, compare, delete problem | Excel Programming |