Search code examples
vbaexcelexcel-2013

Clear Used Range Starting With Specific Cell


I want to clear the used range of Sheet1, but starting with A8 and down. I want to leave the data in A7 and up in-tact, but anything below that range, clear out. I tried this syntax, but it is not going all the way to the end of the workbook ("used range"). And yes, the last cell of the used range is before A65536

For LastRow = 2 To Worksheets("Sheet1").Range("A65536").End(xlUp).Row
  Next LastRow
Range("A" & LastRow).ClearContents

How can I clear all cells with data from row A8 to end of used range?


Solution

  • You are close try the below - this way you do not have to specify the "end range". It will delete everything below row 8

    With Sheets("Sheet1")
        .Rows(8 & ":" & .Rows.Count).Delete
    End With