VBA to delete all VBA codes on sheet

jmazorra

Well-known Member
Joined
Mar 19, 2011
Messages
715
Hello Everyone:

I am looking to integrate a VBA code to delete all codes upon clicking the Exit button ("Private Sub CommandButton9_Click()
") on a spreadsheet.

Since I sent this sheet to clients, I do not want to have all of the codes running in the background. I would also like to get rid of a button "cmdopenform" that shows up in my first sheet. I use it to initiate all of the processes, but the client has no use for it.

Below is what I have on that button right now:

Code:
Private Sub CommandButton9_Click()
Dim MyPath$, MyName$
MyPath = "C:\"
MyName = InputBox("Enter today's date ie: 2011.1018")
MyName = MyName & " Salary Survey " & InputBox("Enter Client Number") & ".xls"
ActiveWorkbook.SaveAs MyPath & MyName
MsgBox "File is Saved Under Your C:\"
Unload Me
Sheet1.Visible = xlSheetVeryHidden

End Sub

Any help is appreciated.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

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