How to apply a button to clear specific cells in Excel?
Normally, you can hold the Ctrl key to select multiple specific cells, and then clear the cell contents as you need. If you frequently need to clear these specific cells from time to time, you can create a clear button to clear them with just one click. In this article, I will talk about how to create a clear all button to clear some specific cell contents.
Apply a button to clear specific cell contents with VBA code
Apply a button to clear specific cell contents with VBA code
First, you should create a shape button, and then apply a code, at last, tie the code to the shape button. Please do as follows:
1. Click Insert > Shapes > Rectangles to select the Rectangle shape, and then drag the mouse to draw a rectangle button anywhere on the sheet as needed, see screenshot:
2. Then input the text and format the shape button as you need, see screenshot:
3. And then you should insert the VBA code, please hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window. Click Insert > Module, and paste the following code in the Module Window.
Sub Clearcells()
'Updateby Extendoffice
Range("A2", "A5").Clear
Range("C10", "D18").Clear
Range("B8", "B12").Clear
End Sub
Note: In the above code: A2,A5 indicate it will clear the cells in the range A2:A5, not just the two cells individually. You can also add multiple ranges, such as Range("B8", "B12").Clear script within the code to clear.
4. Then save and close the code window, and then link the code to the shape button. Right-click the button, and select Assign Macro. In the Assign Macro dialog box, choose the Clearcells code name from the Macro name list box, and click OK button to exit this dialog. See screenshot:
5. And now, when you click the Clear All button, the specific cells you defined are cleared at once, see screenshot:
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.





- All-in-one suite ā Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license ā set up in minutes (MSI-ready)
- Works better together ā streamlined productivity across Office apps
- 30-day full-featured trial ā no registration, no credit card
- Best value ā save vs buying individual add-in