Delete rows with data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have seen several variations on this, but can't get them to work on my
spreadsheet. I have several rows of data(around 600, but it will change each
time). How can I delete all rows that contain any data in column J? When I
did the recording macro, it did this:

Selection.AutoFilter Field: =10, Criteria1:="<>"
ActiveWindow.SmallScroll Down:=-12
Selection.EntireRow.Delete

This works for my original data, but when I tested it on prior data, it
didn't work.

My VBA knowledge is very basic, if you can't already tell. :-)
Any help will be appreciated.

Thanks!
Amy
 
One way:-

Sub mission()
With ActiveSheet
lastrow = .Cells(.Rows.Count, "J").End(xlUp).Row
End With
For x = lastrow To 1 Step -1
Cells(x, 10).Select
If ActiveCell.Value <> "" Then
Selection.EntireRow.Delete
End If
Next
End Sub


Mike
 
Thanks! That worked. Is there any way to make this move faster? It took a
good 5 minutes for this to delete all of the rows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top