-->
Home » Featured, Software, Windows

Delete row in Excel if it contains string

In Excel you can use the allmighty Visual Basic Editor to create very useful macros. Today I will share with you a macro which deletes a row if it contains some string. The code is

Sub delgoogle()
Dim i As Long
With ActiveSheet.UsedRange
For i = .Row + .Rows.Count – 1 To .Row Step -1
If Cells(i, “A”).Text Like “*google*” Then Rows(i).Delete
Next i
End With
End Sub

What this code does, is look in the sheet where the macro is ran, for a row containing the word google. Note the “*” which means that the row can be like agoogle or googlef or even agooglea and will still delete it.

Email This Post
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.