Just wondering


Posted by Cliff on December 26, 2001 7:26 PM

I've added a button to a spreadsheet to delete all cell contents but I had to record a macro and paste it in the command button code. Is there any other way to write code that for a command button that when clicked it will delete the contents of specified cells?

Posted by Derek on December 26, 2001 8:34 PM

Try:
Selection.ClearContents
(deletes contents of all cells selected)



Posted by Jack in UK on December 27, 2001 2:22 AM

Yes i agree with Derek, but add
to clear a cell contence i feel delete is worthless as thisis my reason

Delete just hides the number and omits it from being counted as cant be seen, so in effect that cell is used and even deleted contence still in Exels mind is used, thus the worthless bit.

Not many people know this but try it fill A1:Z6553 full of any data say your name, drag and fill will take a moment save the file as test1.xls and close it - open the file and check the size, a lot biggers now CTRL+A (Select all) and press the delete key and all is deleted, save the file and view the properties, no change????

Odd that.. BUT...

CTRL+A and right click on the selection and clear contence and then select a cell. Now resave and view properrties file size 16 - 25k some reduction there for the same money, no more work just a better way of working.

Now again little known is programmers relay on blank enpty cells and use this for many reasons, like dumping data and removing it later, but Excel wont see deleted cells as empty so the file size explodes.

How many time do we see on this board file size 10mb and growing, or i need last cell of data, often its empty, clean up sheets makes the fast and small, now i never delete unless in table of contence, not worth is.

Sorry to go on im not saying im wirht just my opinion and worth remembering but you choose, right click delete or right click clear contence...

HTH
Jack