Erase Data on Sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I erase all the cells after row 1 on a worksheet when the sheet opens.
 
Private Sub Workbook_Open()
Dim ToErase As Range, EraseRows As Integer

Set ToErase = Sheets("SheetName").UsedRange
EraseRows = ToErase.Rows.Count - 1
If EraseRows > 0 Then
Set ToErase = ToErase.Offset(1, 0).Range("1:" & EraseRows)
ToErase.ClearContents
End If

End Sub
 
Bill

You sure you want to do this?

Private Sub Worksheet_Activate()
Range("A2:IV65536").ClearContents
End Sub


Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top