View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
[email protected] bernd.vd.berg@gmail.com is offline
external usenet poster
 
Posts: 3
Default keyword search and delete row

I've use this macro to delete rows that didn't contain a 0 in column V.
It is the inverse of what you are loooking for, but I think you can use
this macro. You have to add an extra column (take column V in order to
copy paste this macro) where you put a 0 if the special word is in the
row, use an if then else funtion.

---
Sub Reset()
ActiveSheet.Unprotect
Dim NullRange As Range
Set NullRange = Nothing
Application.ScreenUpdating = False
For i = 1 To ActiveSheet.UsedRange.Rows.Count
If Range("V" & i).Value = "" Then 'If cell in column V is empty,
then add to NullRange.
If NullRange Is Nothing Then 'If NullRange were non-empty to
start, this If could be removed leaving the Else action as the only one
to perform.
Set NullRange = (Cells(i, 1))
Else
Set NullRange = Union(NullRange, Cells(i, 1))
End If
End If
Next

If Not (NullRange Is Nothing) Then
NullRange.EntireRow.Delete 'Delete the rows which satisfy the
condition.
End If
Application.ScreenUpdating = True
Call subreset
ActiveSheet.Protect
End Sub
---

Hope it helps.

Bernd

mikeyVo wrote:
I have a database of thousands of contacts. I would like to delete all
contacts with a certain word. is there a way to search for a word,
then if excel finds the word, delete the row? I have been doing it
manually and it is getting too time consuming
Thanks for your help!


--
mikeyVo
------------------------------------------------------------------------
mikeyVo's Profile: http://www.excelforum.com/member.php...o&userid=34277
View this thread: http://www.excelforum.com/showthread...hreadid=567090