• Deleting VBA modules (Excel 2003)

    Author
    Topic
    #435521

    Hi,

    I have a workbook with 3 modules. Module 1 and 3 are used once–basically to create additional worksheets based on input.
    At the end of the Module 1, the workbook is saved with a new name.

    I would like to take away modules 1 and 3 from the new workbook, leaving only module 2. I would put the code in Module 2. Is there code for doing something like this?

    Thanks,
    –Cindy

    Viewing 2 reply threads
    Author
    Replies
    • #1029540

      Are any of the function or routine repeated in the modules?

      If not, I don’t see any reason why you can’t copy all the code from one module to another.

      You might have to clear some “Option Explicit” lines, but that isn’t bad.

      What is your concern about moving the code?

    • #1029545

      You can adapt the code that Chip Pearson has in Programming To The VBE, but it seems to me it would just be easier to do it manually.

      Steve

    • #1029719

      I picked up some code from somewhere and adapted it to set my needs, I have edited it to suit your requirements:

      Sub TidyVBA()
      ‘ Removes VBA Modules from Workbook
      Dim WBCodeItem As Object
      ‘ Create an object reference for the VB Project

      • #1029902

        Thank you Roger …

        I haven’t worked (yet) with object references and stuff like that …
        but I did find a post (584,261) that should help me create an object reference.

        Again, thanks,
        Cindy

        • #1029953

          Cindy,

          I tested it before I posted it so the procedure should work right now as it creates the object reference for itself.

    Viewing 2 reply threads
    Reply To: Deleting VBA modules (Excel 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: