+ Reply to Thread
Results 1 to 3 of 3

Exporting/Importing modules between two workbooks

  1. #1
    Registered User
    Join Date
    08-22-2007
    Posts
    1

    Exporting/Importing modules between two workbooks

    I have a macro that copies four worksheets from the current workbook, creates a new workbook and then pastes these worksheets into the new workbook.

    One of the worksheets refers to a macro that is in the module. How do I export/import the module between the two workbooks. I found some code online that I tried on my macro but when I run it I keep getting a run-time error '9': Subscript out of Range.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello AnnieLilliy,

    You need to set a VBA reference in your workbook with the macro to the Microsoft Visual Basic Extensibility x.x library (x.x is the version on your machine).

    Setting a VBA ProjectLibrary Reference
    1. Open Excel and press ALT+F11 to open the Visual Basic Editor (VBE).
    2. Press ALT+T to activate the Tools Menu.
    3. Press r to show the Refernces Dialog.
    4. Scroll through the list to find Microsoft Visual Basic Extensibility x.x Object Library
    5. Click the Check box to select it. You should see a checkmark.
    6. Click OK
    7. Press CTRL+S to Save the Reference in your project
    8. Press ALT+Q to Close the VBE and return to Excel.

    Sincerely,
    Leith Ross

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I don't remember where I got this utilility, but it works well to export/import VBA components, including modules.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1