To erase cells a few cells...

ssjj23

New Member
Joined
Aug 29, 2006
Messages
17
HI!!!


It is possible to erase the info for certain cells automatically?
I mean, if I fill some cells, and then I need to delete it's content.... is there a way to do it with a push button, function or anything else.

It is tricky to do it manually when the cells are disperse

Thanks!!!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Sure, just replace these ranges with the real ranges of interest.
Code:
Sub ClearSpecifiedCells()
Range("A1:B4, D5, E7, F2:F5").ClearContents
End Sub

(Do you need a hand installing/running the code too, or do you know how to do that already?)
 

ssjj23

New Member
Joined
Aug 29, 2006
Messages
17
Yes please

Thanks for your help.

And yes, I need help to installing/running the code.
Please.

And I would like to know if this code runs every time I want on the document, because I need to do it repeatedly.
Because I will modify some cells of the document and then I need to delete the info to add a new info.

Thanks again.
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
OK, here's how you can create a button on your sheet that will clear the cells every time
you click it.

1) Make sure your Forms toolbar is showing. (From the menu choose View > Toolbars. Make sure 'Forms' has a check next to it, if it doesn't then select it. This will show the toolbar.

2) On the Forms toolbar, click the button of the button and then draw out a button on your sheet where you want it.

3) When you release your mouse button, a window will open up that says 'Assign macro'. In the field below that says 'Macros in:', select ThisWorkbook. In the fiels at the topn, where it says 'Macro name', backspace out whatever's there (probably something like Button1_Click) and replace that with ClearSpecifiedCells and then click 'New'.

You will now be in the vb editor. Simply paste this line:
Range("A1:B4, D5, E7, F2:F5").ClearContents
in between the lines that say:
Sub ClearSpecifiedCells()
and
End Sub

Now, replace those example ranges with the real ranges you want to have cleared out.

When you're all done, press Alt+Q to close the vb editor and get back to your sheet.

You can now right click on the button and choose Edit Text and then replace the existing text there with what you want. (ie. Clear cells) - or whatever suits you. When you right click the button, you'll see it surrounded by some dotted lines & dots. You can use these to move and resize your button to suit.

Now, whenever you click the button, the range(s) you specified in your code will be cleared out for more entries.

Does that help?
 

ssjj23

New Member
Joined
Aug 29, 2006
Messages
17
EXELENT!!!!

Very very thanks yoy for the HELP!!!

It works perfect.

Thanks
 

Forum statistics

Threads
1,141,062
Messages
5,704,046
Members
421,325
Latest member
tapete86

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
Top