Thread: [Solved] Remove rows less than 10
View Single Post
 
Old 07-16-2014, 02:46 PM
jolivanes jolivanes is offline Windows XP Office 2007
Advanced Beginner
 
Join Date: Sep 2011
Posts: 93
jolivanes will become famous soon enough
Default

@ novice.
I am still learning so I'd be really interested in an explanation on why not to use "End(xlUp)"
BTW, if gbaker want to find the absolute last used cell (in any column), that's no problem.


@gbaker
This works on all sheets in your workbook.
If that's not what you want, let us know which sheets to exclude.
Good luck.

Code:
Sub jolivanes()
    Dim lr As Long, lc As Long, sh As Worksheet
    Application.ScreenUpdating = False
    For Each sh In ActiveWorkbook.Sheets
        With sh
            lr = .Cells(.Rows.Count, 4).End(xlUp).Row
            lc = .Cells(1, .Columns.Count).End(xlToLeft).Column
            .Range(.Cells(1, 1), .Cells(lr, lc)).AutoFilter 4, "<11"
            .Range(.Cells(2, 1), .Cells(lr, lc)).SpecialCells(12).EntireRow.Delete
        End With
        sh.AutoFilterMode = False
    Next sh
    Application.ScreenUpdating = True
End Sub
Attached Files
File Type: xlsm testtoremoverows_B.xlsm (185.9 KB, 8 views)
Reply With Quote