Joshua is a graduate student at the USF. He has interests in business technology, analytics, finance, and lean six sigma.
You may want to clear all your work within a worksheet instead of creating a new sheet. If this is the case, you are in the right place. This article will show you how to create a button that will clear every row of a workbook excluding the first row. You'll need to keep the first row so you can keep your button handy for its next use. If you do not have the developer tab (the developer tab is needed in this tutorial) in Microsoft Excel find out how to make it visible here.
Adding the Developer Tab
Step 1: Insert a Button
First, click on the developer tab and choose the insert button. From the form control area of the drop down, chose the button in the first row to the left. The steps are indicated by 1, 2, and 3 in the illustration below.
Inserting a Form Control Button
Next, drag the cursor somewhere in row 1 to create a button. After the outline of the button is drawn the Assign Macro box appears. Click on the record button.
Step 2: Start Recording a Macro
Next, the Record Macro window will appear. Name the macro and click OK. You can tell the macro is recording by the square stop button in the bottom left hand corner of your screen this stop button will stop the macro at any time during recording.
Step 3: Select Area to be Deleted
For this worksheet everything below row 1 needs to be cleared when the button is pressed. Start by selecting row 2. Now press Ctrl + Shift + Down arrow. This will select every row below row 1.
Step 4: Clear The Area
When all the rows are selected go to the home tab. Find the edit group and click on clear. Next click on clear all.
Step 5: Stop Recording The Macro
Press Ctrl + home to get back to the top of the workbook if necessary and click somewhere in the worksheet to deselect the selected cells. Now click on the stop button to the right of “ready” in the bottom left hand corner. Now the macro has finished recording and the button that was drawn earlier should appear. When the button is clicked it will clear any formatting or text below row 1.
Formatting the Button
To format the button right click on the button and click on Format Control.
When the Format Control window appears, you will be given a number of options. Each tab option is listed in the table below. Make any necessary changes to format your button.
Change font type, size, style, color, and effects
Change text alignment and text direction
Change height and width or scale of the box
Lock options for a protected sheet
Change object positioning
Change internal margin
Change text that appears on button
Closing the Workbook
When using macros in workbooks they must be saved under the file name .XLSM to represent a macros workbook. If the workbook is not saved under this file extension, the macro the you created will not function at all. To save, select the File tab then Save As. Select the location to save in and create a file name. Next, find Excel Macro-Enabled Workbook from the “Save as type” drop down. Now save the workbook.
Please see the video below titled "Creating a Macro Button to Clear a Whole Worksheet" if you were unable to learn with the article.
Creating a Macro Button to Clear a Whole Worksheet
Crowder, J. (2020, January 1). How to Add the Developer Tab in Excel. Retrieved January 1, 2020, from https://youtu.be/nskuG6pK5ig.
- How to Create a Macro Button to Save & Close an Excel Workbook
The article describes how to create a macro button on an Excel spreadsheet that will save and close a workbook to avoid having to select both operations.
- How to Add the Developer Tab in MS Excel 2016
This article shows you how to navigate through the MS Excel options menu to enable visibility of the developer tab within the Excel main menu.
- Create a Macro Button in MS Excel 2016 to Filter Data
The article will show you how to create a set of buttons allowing you to filter a table within a spreadsheet and revert to your original view quickly. A document template for the task will be provided.
- How to Create a Button in Microsoft Excel That Opens a Calculator
Shows a Microsoft Excel user how to create a button that opens up the Windows pre-installed calculator application from an Excel spreadsheet.
To learn more about developing in Excel, I recommend taking a look at the book Microsoft Excel 2019 VBA and Macros (Business Skills) by Bill Jelen to enhance your skills.
This content is accurate and true to the best of the author’s knowledge and is not meant to substitute for formal and individualized advice from a qualified professional.
© 2018 Joshua Crowder
Joshua Crowder (author) from Tampa, FL on December 02, 2019:
Thanks! I just wanted to show that everything can be deleted if you want.
Farah Kiaei on February 27, 2019:
Great idea that how much is important to clear every row of a workbook excluding the first row.