Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Mar 2006
    Location
    Princeton, New Jersey, USA
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Deleting VBA modules (Excel 2003)

    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

  2. #2
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Cincinnati, Ohio, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting VBA modules (Excel 2003)

    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?

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Deleting VBA modules (Excel 2003)

    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

  4. #4
    Lounger
    Join Date
    Nov 2001
    Location
    Calgary, Alberta, Canada
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting VBA modules (Excel 2003)

    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

  5. #5
    Star Lounger
    Join Date
    Mar 2006
    Location
    Princeton, New Jersey, USA
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting VBA modules (Excel 2003)

    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

  6. #6
    Lounger
    Join Date
    Nov 2001
    Location
    Calgary, Alberta, Canada
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting VBA modules (Excel 2003)

    Cindy,

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •