code deleteremove code

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Code to delete/remove code

Code to delete/remove code

resolvedResolved · Low Priority · Version 2003

Matt has attended:
Access Intermediate course
Excel VBA Intro Intermediate course
Excel VBA Advanced course

Code to delete/remove code

Hi,

Alot of the reporting I do is issued out to the business and to people who dont nessesarily understand excel or VBA. At the moment i manually remove the code from the version for distribution so that is doesnt run when the open it. Is these an instruction I can build into my current mudule that will remove the code automatically?

Thanks

RE: Code to delete/remove code

Hi Matt

Thanks for your question

I am not aware of anyway to remove code from a module automatically.

I assume you are running code on a workbook, and want then to send that work book out without the code.

I would write the code in a separate workbook, and reference the workbook you want to send out in the code. So the code would be written in one workbook, but make changes to another.
You could then send this out without needing to delete the code, as that would be in another workbook.

Regards

Stephen

RE: Code to delete/remove code

Hi Stephen,

Thanks for your response. When I get a chance to rebuild the report I'll give it a go.

I did have a quick flick through various forums and came across some code. I have'nt tried it yet but wonder what you thought (pasted below). It makes sence to me but I'm resonably new to VBA. This would be run from a seperate module (Not "ThisWorkbook").

Sub DeleteWorkbookEventCode()

''Needs Reference Set To _

"Microsoft Visual Basic For Applications Extensibility"

'Tools>References.

With ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule

.DeleteLines 1, .CountOfLines

End With

End Sub


Thanks

Matt

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Adding a comment to a formula

1. At the end of the formula, add a + (plus) sign.
2. Type the letter N, and in parentheses, type your comment in quotation marks.

eg.

=CurrentAssets / CurrentLiabilities+ N("The formula returns Current Ratio")

View all Excel hints and tips


Server loaded in 0.08 secs.