Programmatically Add Code to a Sheet Module

  • Hi everyone,

    Long time forum browser, first time posting.

    Is there a way via VBE to programmatically add an event change handler to a sheet module? I searched many threads, and most suggestions involve a template or a copy and paste. What I'd like to do is write the event change code in an existing macro, so when the new sheet is created the code is inserted into the module.

    If that isn't a viable option, then perhaps I could contain the code in a normal code module in my personal workbook and find a way to copy it to the appropriate sheet module.

    A quick explanation of the scope: I receive a data dump from another system delivered in xls. I have written code that cleans up the data, adds a number of formulas and puts the data in a fresh workbook. The problem is, I have created a dropdown via data validation and I need the worksheet change handler in this new workbook/sheet.

    Once complete, I plan on creating an addin so end users have the same functionality. So I'd like this to be as self-contained as possible.

    Thank you in advance for taking the time to read this, and I look forward to your guidance.


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!