Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default keyword search and delete row


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

  #2   Report Post  
Posted to microsoft.public.excel.misc
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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 269
Default keyword search and delete row

Here's an alternate way to do it. Might be a bit crude, but it's
simple and effective. Copy and put in a standard module. Change Const
WordToFind to whatever it is you want to find. Change Const Col to
whatever column you want to look in. Sub presumes sheet is not
protected. Also note that it will delete if "draw", "Draw", or "DRAW"
is matched. James

Sub SearchAndDestroy()
Const WordToFind = "draw"
Const Col = "a"
Dim k As Long
For k = Cells(65535, Col).End(xlUp).Row To 1 Step -1
If InStr(1, Cells(k, Col), WordToFind, vbTextCompare) 0 _
Then Rows(k).EntireRow.Delete
Next k
End Sub

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


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
Search & delete ANY text in select columns huruta Excel Discussion (Misc queries) 2 June 30th 06 07:31 PM
How administrator can delete temporary excel file generated on se Suhas Sakalikar Excel Discussion (Misc queries) 9 June 8th 06 12:47 PM
Delete quota from a cell Manos Excel Discussion (Misc queries) 2 March 21st 06 06:31 AM
Delete blank rows Macro Richard Excel Discussion (Misc queries) 3 November 4th 05 08:02 AM
Delete graphics copied from a Web page Jim Georgia Excel Discussion (Misc queries) 1 October 20th 05 02:47 PM


All times are GMT +1. The time now is 10:38 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"