Finding a specific text
You can use something like this:
Sub Find_Cells()
On Error GoTo Error_Handler
Range("B2").Select
Do Until ActiveCell = ""
ActiveCell.Find(What:="NHA", MatchCase:=xlYes).Activate
Next_Case:
ActiveCell(2, 1).Select
Loop
Error_Handler:
If Err.Number = 91 Then
Activecell.EntireRow.Delete
Activecell(0,1).Select 'Because deleting the row will shift up the next row
Resume Next_Case
End If
End Sub
"Don Doan" wrote:
Hi there,
I'm new to macro and I need some help with the program.
Basically, from cell B2 to B25...i want to look for the three character NHA
(in that order). If it's not there, erase the whole row. If it's there, keep
the row. There may be some characters or spaces before and after that word
NHA.
I a few lines in the program. If someone can help me modify it, that would
be great.
Sub Macro1()
Dim k As Long
For k = Cells(25, "b").End(xlUp).Row To 2 Step -1
If Cells(k, "b") < "*NHA*" Then
Rows(k).EntireRow.Delete
End If
Next k
End Sub
|