How to delete all rows except the first header row in Excel?
Sometimes, you may need to clear all contents except the first header row in order to update all data again. This article will show you method of deleting all rows except the first header row in Excel.
Recommended Productivity Tools for Excel
Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial
Kutools for Excel: Save 71% of your time and solve 82% Excel problems for you. 300+ advanced tools designed for 1500+ work scenario, make Excel much easy and increase productivity immediately.60-day Unlimited Free Trial
The following VBA code can help you delete all rows except the first header row in Excel. Please do as follows.
1. Press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module. Then copy and paste the following VBA code into the Code window.
VBA code: Delete all rows except the first header row in Excel
Sub DeleteExceptFirst() Rows("2:" & Rows.Count).ClearContents End Sub
3. Press the F5 key to run the code, then all rows except the first header row are deleted from the active worksheet immediately. See screenshot:
- How to delete all rows below certain row or active cell in Excel?
- How to delete rows if cell is greater/less than a certain value in Excel?