Deleting a line with a key word in it


Posted by Julie on June 26, 2000 9:01 AM

I have a spread sheet that has a key work in it. I want a macro that finds all occurances of this word, then clears contents in this line. This needs to then loop to the next line.

Posted by Julie on July 13, 0100 7:01 AM

The macro works great with 'ClearContents', however, I can't clear the whole line because there are formulas in some cells, anymore suggestions?

Thanks!

Posted by Julie on July 06, 0100 9:39 AM

Ryan,

I tried the macro, but it did not work, I checked the code very carefully and found no mistakes, did I miss something?

Julie

Posted by Ryan on June 26, 0100 11:01 AM

Hi Julie,
Here is some code that will take care of your problem. It searchs for the key word and deletes the whole row that has the word in it. It keeps looping until there are no more. Where it says "InsertWordHere", replace this with your "key word." Hope it's what you need. Let me know.

Ryan

Sub SearchAndDelete()
Dim Row As Integer

On Error GoTo ErrHandler

Application.ScreenUpdating = False

Do
Row = Cells.Find(What:="InsertWordHere", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False).Row
Rows(Row).Delete Shift:=xlUp
Loop

ErrHandler:
Application.ScreenUpdating = True
Exit Sub

End Sub



Posted by Julie on July 06, 0100 11:33 AM

The macro worked great - once I figured out that 'xl' NOT 'x1' Silly me, but I still net to ClearContents and not delete the ROW.

Thanks