Advice for removing command button & its code

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
6,131
Office Version
  1. 2024
Platform
  1. Windows
Quite often i find myself changing the look of my user form.

So for example i wish to delete a command button & its code.
I go into the design page & delete the code then open the user form & delete that command button in question.

Is the above the correct way to do it or if not please advise.

I ask as if i delete the command button it leaves the code behind & then i end up with a design page of dead code that isnt assigned to a command button etc.
 
The way you are doing it is the textbook method, but you have to make sure that you are deleting all the code that references the button, and you have to also make sure that you don't delete code that is needed for something else. If you just have a single Click sub then it's pretty simple and risk-free. (Sometimes people do fancy things with buttons like change the color or caption dynamically based on other actions, which makes it harder to identify which code has to be deleted.)

Leaving the dead code is not harmful but will cause confusion for future maintenance of the code. It's better to remove it.
 
Upvote 0

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