AutoFilter and deleting blank rows

drozek

Board Regular
Joined
Aug 3, 2011
Messages
67
I wrote this macro, but I feel like it can be written better, I used the macro recorder to write. Any suggest of how to delete what is seen on the screen instead of the selection.end down and right? I am filtering any blanks in Col 6 and delete all these blank cells based on the blanks in Col 6.

ActiveSheet.Range("$A$1:$N$817").AutoFilter Field:=6, Criteria1:="="
Columns("A:A").Select
ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 2).Select
ActiveCell.Offset(0, -1).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.EntireRow.Delete
ActiveSheet.Range("$A$1:$N$790").AutoFilter Field:=6
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try this

Code:
Sub test()
    Dim sh As Worksheet
    Set sh = ActiveSheet
    Application.ScreenUpdating = False
    sh.Range("$A$1").AutoFilter 6, "="
    sh.AutoFilter.Range.Offset(1).EntireRow.Delete
    sh.ShowAllData
End Sub
 
Last edited:
Upvote 0
Try this

Code:
Sub test()
    Dim sh As Worksheet
    Set sh = ActiveSheet
    Application.ScreenUpdating = False
    sh.Range("$A$1").AutoFilter 6, "="
    sh.AutoFilter.Range.Offset(1).EntireRow.Delete
    sh.ShowAllData
End Sub


Perfect thank you very much works so much better.
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top