fungrymonster
fungrymonster

Reputation: 25

delete row with value excel

I am trying to make a code that looks for a file extension then deletes that row.This is what I have so far

With Worksheets("ImportSheet")
For lRow = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row
    If Cells(lRow, 1).Value = "*xlsx" Then
        Rows(lRow).Delete
    End If
Next
End With

But it doesn't seem to do anything. Help greatly appreciated. Thank you in advance

Upvotes: 1

Views: 39

Answers (1)

Vinnie
Vinnie

Reputation: 553

Try this:

With Worksheets("ImportSheet")
For lRow = .Cells(.Rows.Count, 1).End(xlUp).Row To 2 Step -1
    If Cells(lRow, 1).Value Like "*xlsx" Then
        Rows(lRow).Delete
    End If
Next
End With

Upvotes: 1

Related Questions