+ Reply to Thread
Results 1 to 2 of 2

import worksheet into workbook

  1. #1
    Registered User
    Join Date
    07-15-2010
    Location
    Cumbria
    MS-Off Ver
    Excel 2007
    Posts
    9

    import worksheet into workbook

    Hi

    I'm hoping someone can help me with this as I am at my wits end after searching all afternoon for a solution or at least some information which could point me in the right direction and coming up short.

    I'm looking for the code or something, which automates an import of a worksheet from one workbook into another. The imported worksheet contains buttons with macro's assigned to them and I need all code, macros and buttons to be imported too.

    I have created an excel worksheet that at a click of a button allows you to import .txt files and then assigns the text files to worksheets within the workbook. On top of this as part of the .txt import I would like a page in the new workbook to be created which contains buttons with assigned macros. This is where I thought It would be better to create an external workbook and have this imported alongside the .txt files.

    I'm looking for the code or something, which automates an import of a worksheet from one workbook into another. The imported worksheet contains buttons with macro's assigned to them and I need all code, macros and buttons to be imported too.

    I'm not entirely sure how clear this is to everyone but I hope it 'sort of' makes sense at least. Is it even possible?? Any help or points in the general direction of the solution would be greatly appreciated.

    Many thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: import worksheet into workbook

    Hi

    I use the following code to copy a sheet ("EmailFile") in ThisWorkbook and save it as a new workbook (varNewWorkbook). Next I export Module1 from ThisWorkbook and, after deleting all VBA in varNewWorkbook, I import Module1 into varNewWorkbook . Finally, the macros linked to the command buttons on the sheet are changed to Module1 in varNewWorkbook.

    With a little teaking you could copy the sheet into an exisiting workbook, rather than creating a new one.

    Regards

    Dion


    Please Login or Register  to view this content.

+ 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