Thread: Delete cells
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Delete cells

This would be the opposite to the solution you were
given last month to delete matches. In this case you
simply need to modify that solution to delete
non-matches instead of matches.<g


Without going back to try and find it, I would be willing to bet the
modification to it would not look like this...

Sub RemoveBeginningMatchesToColumnA()
Dim X As Long, LastRow As Long, UnusedColumn As Long
Const StartRow As Long = 1
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
UnusedColumn = Cells.Find(What:="*", SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns, LookIn:=xlFormulas).Column + 1
Application.ScreenUpdating = False
With Cells(StartRow, UnusedColumn).Resize(LastRow - StartRow + 1)
.FormulaR1C1 = "=MATCH(LEFT(RC2,16),C1,0)"
On Error Resume Next
.SpecialCells(xlFormulas, xlErrors).Offset(, _
2 - UnusedColumn).Delete xlShiftUp
.Clear
End With
Application.ScreenUpdating = True
End Sub

Rick Rothstein (MVP - Excel)