Skip to content

Instantly share code, notes, and snippets.

@ateneva
Last active March 4, 2018 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ateneva/ae4953135b7cc7688dca6d36a7536557 to your computer and use it in GitHub Desktop.
Save ateneva/ae4953135b7cc7688dca6d36a7536557 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment