Create A Macro To Delete Cell Data – Excel 2007
The first step will be the addition of a new button on the Quick Access Toolbar ( QAT).
Step 1 - Go to the Logo / Options / Customize / All Commands and choose “Button(Form
control)” and add it to the QAT.
Step 2 - Next you create data in the worksheet upon which the macro will be acting. Color the
data cells for example except for the column headers – Home tab / Fill color in the Font group.
When you select the button which begins the macro, all entered data will be cleared from the
Select the button tool that you added to the QAT toolbar. When you move the cursor back into the
worksheet it will have changed to a cross-hair. Decide where you want to place the button, then
click and drag to draw the size of the button.
Step 3 - Name the macro with no spaces (ex., Clear_data), and use the drop down menu beside
Macros in: to select This Workbook.
Step 4 - Now Record the Macro - in the Assign Macro window click on Record to start recording
In the Record Macro window choose any key that will be used with the CTRL key and click OK.
Stay away from those that you know and use often.
The advantage of using a button to initiate the macro is that you do not have to remember the
Step 5 - Now perform the action you want the macro to perform later: select the colored cells
mentioned above. After all cells that are to be cleared have been selected, choose the Home tab /
Clear Contents from the Editing group.
Step 6 - Stop recording the macro - When the colored cells have been cleared, stop the macro by
going to Developer tab / Stop recording.
Test it : Put data in the colored cells then click on your Macro button to delete it!
If you automatically get the message that the macros are disabled you must change the security
level in excel. On the Developer tab select Macro Security. Change your security setting to
Enable all ….
When you then get ready to save it, save it as an xlsm ( .xlsm ) file ( Macro enabled