Remove VB code from a sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a few comboboxes on a worksheet and when the user saves the worksheet,
a macro removes all the comboboxes. I was digging through the forum to find a
way to eliminate the code from a worksheet, but I read a post that said it
couldn't be done.

Is that true? If it is not true, where can I find code to eliminate code?

Thanks.
 
Thank you for your reply. I will dig around on Chip's website, but initially,
the page you pointed me to is not the information I want to find. That page
refers to removing/adding code to a MODULE - I want to remove code from a
WORKSHEET.

Explaination:
I have code in the worksheet that monitor calculations and changes to
certain values and comboboxes and when the sheet is "saved", it is copied to
a new workbook and controls are removed. Well now I would like to apply one
more bit of code to remove the worksheet code when it is copied into the new
workbook.
 
Ignore my other post.

I glanced over it and, of course, as soon as I dug into it like I said I was
going to, I now have to eat my words.

Thanks again, Norman.
 
You can remove the code from a sheet module with code like the following. It
will remove the code behind MySheet.

With ThisWorkbook
With .VBProject.VBComponents(.Worksheets("MySheet").CodeName).CodeModule
.DeleteLines 1, .CountOfLines
End With
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting LLC
www.cpearson.com
(email on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top