ateneva
4/16/2017 - 2:17 PM

Get rid of Excel unused range

Get rid of Excel unused range

Sub GetRidOfUnUsedRange()

Dim Wks As Worksheet
Dim i As Integer
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, September 2016
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For Each Wks In ActiveWorkbook.Worksheets
    If Wks.Index > 18 Then Wks.Activate
    
        With ActiveSheet
            'reaches the last populated cell and goes to the next row
            Range("A2").End(xlDown).Offset(1, 0).Select
            
            'uses the curently active cell and goes to the last one of the range
            Range(ActiveCell, ActiveCell.SpecialCells(xlLastCell)).EntireRow.Delete
        End With
    
Next

ActiveWorkbook.Save
End Sub