VBA macro: clear contents in a worksheet except the first row

  • Hi, I try to use below code to clear all content and formatting of a worksheet except keeping the first row. It works successfully but as max no of rows in Excel 2007 onwards is 1,048,576 while Excel 2003 or below is 65,536 , seems it cannot cater all scenarios. Any suggestion? Thanks!


    Sub clearExcelContent()


    Rows("2:65536").Select
    Selection.Clear
    Range("A2").Select


    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!