MACRO which deletes a row, when it finds a specific number

  • Thread starter Thread starter Spiros
  • Start date Start date
S

Spiros

Hi,

I want to create a macro which find one specific number in the column B and
delete the row.
For example: There is the number 60 in the cell B15 by accident. The macro
will delete the row No 15.

Thanks in advance,
Spiros
 
You could apply autofilter to column B, select 60 from the drop-down,
highlight the visible rows and Edit | Delete Row. Then select All from
the drop-down.

Hope this helps.

Pete
 
Guys thank you for your suggestions.
I find this macro end it works.

Sub testme02()

Dim myRng As Range
Dim FoundCell As Range
Dim wks As Worksheet
Dim myStrings As Variant
Dim iCtr As Long

myStrings = Array("60") 'add more strings if you need

Set wks = ActiveSheet

With wks
Set myRng = .Range("b2:b" & .Rows.Count)
End With

For iCtr = LBound(myStrings) To UBound(myStrings)
Do
With myRng
Set FoundCell = .Cells.Find(what:=myStrings(iCtr), _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Delete
End If
End With
Loop
Next iCtr
End Sub

Ο χÏήστης "Don Guillett" έγγÏαψε:
 
Back
Top