VBA to delete all VBA codes on sheet

jmazorra

Well-known Member
Joined
Mar 19, 2011
Messages
707
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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Watch MrExcel Video

Forum statistics

Threads
1,129,816
Messages
5,638,496
Members
417,029
Latest member
lingx86

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
Top