View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default VLookup with criteria and delete row

You can't use formulas to delete rows -- you must use VBA code. The
following code will delete all the rows on Sheet1 that have "abc" in column
A.

Dim RowNdx As Long
Dim LastRow As Long
With ThisWorkbook.Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If StrComp(.Cells(RowNdx, "A").Value, _
"abc", vbTextCompare) = 0 Then
.Rows(RowNdx).Delete
End If
Next RowNdx
End With


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


"capt" wrote in message
...
What is the best code to use to look for a name ( col A) and delete the
whole
row.
--
capt