'Updateby20140314
Dim rng As Range
Dim InputRng As Range
Dim DeleteRng As Range
Dim DeleteStr As String
xTitleId = "Delete line"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng. Address, Type:=8)
DeleteStr = Application.InputBox("Delete Text", xTitleId, Type:=2)
For Each rng In InputRng
If rng.Value = DeleteStr Then
If DeleteRng Is Nothing Then
Set DeleteRng = rng
Else
Set DeleteRng = Application.Union(DeleteRng, rng)
End If
End If
Next
DeleteRng.EntireRow.Delete
End Sub
Step 4: When a dialog box appears, select the data area containing the line to delete into the input box. Then press OK .
Step 5: When the next dialog box appears, enter the condition value of the line you want to delete into the box. Then press OK to complete.
So you have completed deleting rows containing conditions in Excel using VBA code.
Above are 2 simple ways to help you delete conditional rows in Excel quickly and accurately. We invite you to read and apply.