+ Reply to Thread
Results 1 to 14 of 14

Import named sheet from multiple excel files into a single sheet in defined excel file

  1. #1
    Registered User
    Join Date
    02-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Import named sheet from multiple excel files into a single sheet in defined excel file

    I need to copy a specific sheet from every excel file within a folder to an existing template excel file, into a single sheet with no spaces between the data. I want it to run as a loop; preferably behind the scenes, I don't mind if the files are opening.

    Copy Range A3:0 to LastCell from worksheet “JV Upload”, from every “*.xls” file within folder path “P:\BK\May 16 - Apr 17\3. July”.

    Paste the copied data as Values into an existing workbook (which I would be running my Macro out of), Filename:="P:\BK \May 16 - Apr 17\BS.xlsm" onto an existing worksheet named "BS", starting in cell A3.

    p.s. this is my first post.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    Re: "starting in cell A3."
    I assume that you have data (Headers?) in Cells A1 and A2. Right?

  3. #3
    Registered User
    Join Date
    02-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    That is correct. A1:O2 have headers, the headers are the same on all sheets including the one I am trying to merge all of the other sheets into.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    Any particular part of Europe you love?
    Try this
    Check all references, Sheets, Ranges etc and change where required.
    Also, to be safe, try it on a copy of your workbook first.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    Thank-you! I am not having much luck right now, but it could be because I am trying to log into my work computer remotely to do it. I may have to wait until I am back in the office on Monday to try again.

    It didn't do anything when I tried it. I did make a backup of my files though to be safe before attempting to run it.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    It worked when I tried with 12 workbooks in a folder.
    What I did is make a temp folder, copied a bunch of workbooks into it, obviously changed the path in the code and ran the code.
    You have to make sure that your path is actually "P" and whatever.

  7. #7
    Registered User
    Join Date
    02-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    Hello, back at work and trying this again.

    The Do Until Loop seems to be not working as sName is not storing a value. It is blank going into the loop, so the loop is skipped when running.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    The 2nd line in the code gives the path. You must have this wrong. An extra space, a missing space or whatever. It has to be exact.
    Copy and paste it and see what happens.

  9. #9
    Registered User
    Join Date
    02-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    I was missing the last \ on the file path...

    So, now it is working the only thing I still need is for it to paste the data as values instead of linking back to the original file.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    I don't know what the best way would be but try this just before your "End Sub" line
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    02-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    It is giving me Run-time error '9':Subscript out of range

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    I do not know anything about links but from what I read it can be a pain.
    But this should, if my thinking is right, only copy the values across.
    See if it works for you.

    Replace this
    Please Login or Register  to view this content.
    with this
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    02-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    Thank you, thank you, thank you! This worked like a charm

    Here is the code you gave me but all together with the modifications you sent:



    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Import named sheet from multiple excel files into a single sheet in defined excel file

    I am glad that it works for you.
    Good luck

+ 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] How to Import data from multiple pages of a website into a single Excel sheet
    By JigneshBavishi in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-06-2016, 11:55 PM
  2. Replies: 0
    Last Post: 10-12-2015, 10:02 AM
  3. Import data from multiple pages of a website into a single Excel workbook
    By kavin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-26-2015, 04:19 AM
  4. how to import external excel files data into a single sheet
    By diga in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2013, 12:11 PM
  5. Consolidating a single named sheet from multiple files into one workbook
    By Eastboston in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2012, 02:29 PM
  6. Handling multiple txt files within single excel sheet
    By 5mkh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2012, 08:12 AM
  7. Import tables from multiple Word files into a sheet of Excel
    By magdy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2012, 03:53 AM

Tags for this Thread

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