cells.delete

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I was doing cells.clear then I thought of doing cells.delete. To my surprise, when I click on a button to run the code below, everything got deleted including the button. So I left with a clean sheet. What I thought would happen is that the who sheet will get deleted and also why the control button got deleted since it is not part of any cell? Thank you so much.


Code:
Sub deleteall()
    Cells(1, 1).Delete
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
That code does not delete everything, it deletes A1 & shifts the below up 1 row
 
Upvote 0
sorry wrong code I paste. so sorry
Code:
Sub deleteall()
    Cells.Delete
End Sub
 
Upvote 0
Whilst deletes all cells, it doesn't delete any buttons.
What type of buttons are you using? Form controls or ActiveX?
 
Upvote 0
If I put a FormControls Button, from the Developer tab on the sheet, it does not get deleted.
 
Upvote 0
If I put a FormControls Button, from the Developer tab on the sheet, it does not get deleted.

It does get deleted for me using 2010, ActiveX buttons aren't getting deleted (disappearing from the Find-Selection pane as well so pretty sure it is actually deleted).


Edit: a bit strange as a button is getting deleted but a group box isn't :confused:
 
Last edited:
Upvote 0
With 2013 no controls get delete, but shapes do.
 
Upvote 0
I am using office 365. Developer-->Insert-->Form control-->Button
and it get deleted when I click on it to run that macro. Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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