+ Reply to Thread
Results 1 to 7 of 7

Import worksheet from another workbook

  1. #1
    Registered User
    Join Date
    11-17-2017
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    14

    Import worksheet from another workbook

    Hi,

    I am trying to import a worksheet from another workbook into the active workbook. The imported sheet comes from a workbook who's name always changes but will be in the same path. The sheet I want to be imported is called "Market Share adj" Thanks for your help!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Import worksheet from another workbook

    Since the source file name always changes, it might be best to allow you to choose the file. Place this macro in the active workbook and run it from there.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    11-17-2017
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    14

    Re: Import worksheet from another workbook

    Thank you for your response. It works exactly as you said.

    Is it possible to have it automatically choose the file that is in the folder and import it? There will always be only 1 macro enabled workbook in that file but the name can change. This is also an intermediate step in a macro I am trying to build so I would like it to all be automated.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Import worksheet from another workbook

    What is the full path of the folder containing the source file?

  5. #5
    Registered User
    Join Date
    11-17-2017
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    14

    Re: Import worksheet from another workbook

    The folder will always be called 48m Macro and it is on a shared network. The path could change depending on what projects are being worked on or if a new project starts. The original code is able to open the file I want but I don't know how to copy the sheet. I am trying to reengineer this macro and build a new macro at the bottom of it.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,888

    Re: Import worksheet from another workbook

    Since you have Excel 2016. I'd recommend using PowerQuery/Get&Transform. It's pretty easy to select only .xlsm in the folder.

    Basic process:
    1. Data tab -> "New Query" -> "From File" -> "From Folder"
    2. Navigate to and pick the folder you need.
    3. This will create preview table with file attributes. Hit Edit.
    4. Select [Extension] column and right click "Transform"->"UPPERCASE". This is to accommodate for cases where files are manually renamed and extension has difference case.
    5. On the same column, filter for ".XLSM"
    6. Click on Binary field and drill down.
    7. This will list Tables and Sheets (named range as well I believe), Filter for the specific sheet name.
    8. Remove all but the [Data] column.
    9. Expand and change data type on expanded column as needed.
    10. Perform any additional transformation needed and load to sheet.

    This process is dynamic as long as there is only one file in the folder with ".XLSM" and sheet name does not change. You can just refresh the table and any changes on specified sheet will be brought back in.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Import worksheet from another workbook

    In your Post #3 you asked:
    Is it possible to have it automatically choose the file that is in the folder and import it?
    Since you originally said that the source file name can change and now you say that the folder path can also change, then I can't see how it is possible to have the macro open the file automatically. As the old saying goes, it's like trying to hit a moving target. When you say:
    I don't know how to copy the sheet
    the macro I suggested does exactly that. I don't know if I'm missing something.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA - Import 3 worksheet Data from Another workbook
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-24-2014, 02:28 PM
  2. [SOLVED] Import from 2nd workbook to specific worksheet
    By ERoemer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2013, 03:15 PM
  3. import variable worksheet from other workbook
    By stunner1901 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2012, 06:47 PM
  4. Import workbook as worksheet in the active workbook
    By legendkiller420 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2010, 06:07 AM
  5. import worksheet into workbook
    By daz18983 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2010, 04:50 PM
  6. Import worksheet from different workbook in current workbook (URGENT)
    By IntosH in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-26-2009, 07:56 AM
  7. How do I import an XLT worksheet into another workbook?
    By chris5 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2005, 08:05 AM

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