View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Remove VB code from a sheet

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").Cod eName).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)


"IT_roofer" wrote in message
...
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.

"Norman Jones" wrote:

Hi IT_Roofer,

See Chip Pearson at:

Programming To The Visual Basic Editor
http://www.cpearson.com/excel/vbe.htm

See particularly the section entitled:

Deleting A Module From A Workbook

but do read Chip's page introduction in full!



---
Regards,
Norman


"IT_roofer" wrote in message
...
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.