Create a Macro Button That Will Clear All of Your Work Within an Excel Worksheet
You may want to clear all your work with in 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.
Step 1: Insert a Button
First, go to the developer tab and insert a new button. Follow these steps starting with the developer tab: Developer tabàInsertàbutton (form control). The steps are indicated by 1, 2, and 3 in the illustration below.
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 workbook 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 is 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.
Fomatting 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.
This article is accurate and true to the best of the author’s knowledge. Content is for informational or entertainment purposes only and does not substitute for personal counsel or professional advice in business, financial, legal, or technical matters.
Questions & Answers
© 2018 Joshua Crowder