ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear cells (https://www.excelbanter.com/excel-programming/357463-clear-cells.html)

Hitu

Clear cells
 
How can I Clear range of cells (e.g. a1,,a10) using a command button on a
worksheet??? I want to use VBA.

Paul B

Clear cells
 
Hitu, use this code for your command button

Range("A1:A10").ClearContents
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Hitu" wrote in message
...
How can I Clear range of cells (e.g. a1,,a10) using a command button on a
worksheet??? I want to use VBA.




Tom Ogilvy

Clear cells
 
make the control toolbox toolbar visible. Click on the commandbutton and
then rubberband its location on the worksheet. You will be in design mode.
Double click on the command button and you should see

Private Sub Commandbutton1_Click()

End Sub

in the procedure put your code

Private Sub Commandbutton1_Click()
Range("A1:A10").Clear
End Sub


go back to the worksheet (alt+F11),
then click the button on the upper left corner of the commandbar to get out
of design mode. Now click the button and it should clear the cells.
--
Regards,
Tom Ogilvy



"Hitu" wrote:

How can I Clear range of cells (e.g. a1,,a10) using a command button on a
worksheet??? I want to use VBA.



All times are GMT +1. The time now is 10:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com