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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,958
Messages
6,175,642
Members
452,663
Latest member
MEMEH

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