Clearing multiple cells

SeanM

New Member
Joined
May 1, 2002
Messages
3
I would like to have a created button on my spreadsheet that when pressed will clear multiple cells of its data...How can this be done.

Any info is greatly appreciated!!!
Thanks SeanM
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
First you need to define the cells to be cleared. If it is a static range of cells that will be cleared each time then naming the range is the starting point.(Insert/Name/Define)

Then, if you use the macro recorder, following these steps once your recorder is running:

Edit/Go To/ type name of range/OK
Then Edit/Clear/Contents

End macro.

As for assigning the macro to a button:

View/Toolbars/Forms. Click on button, drag onto spreadsheet. Text box will ask you to assign a macro - select teh one you just recorded.

I think thats all the steps


Nobby
 
Upvote 0
Write the macro:

Code:
sub clr
[a1:b25].clearcontents 'a1 through b25 go bye-bye
end sub

Click view->toolbars->forms

Click the button, draw it, you should be prompted to assign a macro, highlight clr and assign it.
 
Upvote 0
If you don't need to specify a specific range of cells each time, just record a macro of you clearing what you need to clear, name it, then insert a button into your sheet that executes the macro. Otherwise, you will need either a userform, or have Excel pull your clear range from the sheet itself and assign the range values to variables in your macro.
 
Upvote 0
To clear all cells use:
cells.select
selection.clear 'clears formula, data,etc
or try
selection.clearcontents 'which will clear data and not formulas and formatting.

For a range try:

Range("A1:Z50").select
selection.clear
 
Upvote 0
waderw,

you don't need select selection there,

Range("A1:Z50").clearcontents

does the trick.

RET79
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,395
Members
448,891
Latest member
tpierce

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top