+ Reply to Thread
Results 1 to 9 of 9

Macro Multiple excel files into one workbook as separate sheets

  1. #1
    Registered User
    Join Date
    04-24-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    8

    Macro Multiple excel files into one workbook as separate sheets

    Hi,

    I'm looking for a macro that can consolidate multiple files in a folder to one workbook as separate sheets. I have a found a few hints on how to merge all the info to one sheet but I need to keep it separate. Its would need to follow this basic path.

    - Take files from single folder
    - Open all of then in one workbook as separate sheets
    - Rename each sheet to the original file name.

    The information I need to consolidate is a daily report so the macro would need to be able to work new files being added daily.


    Would really appreciate any help on this.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro Multiple excel files into one workbook as separate sheets

    something along the lines of:
    Please Login or Register  to view this content.
    changing E:\folder\ to whatever the folder where your files are stored is.

  3. #3
    Registered User
    Join Date
    04-24-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro Multiple excel files into one workbook as separate sheets

    Thanks for this,

    I've changed the E:\folder\ but it only seems to be opening one of the files from the folder rather than opening all the files into the totals workbook as sheets. Is it something to do with the file address?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro Multiple excel files into one workbook as separate sheets

    Can you post what you changed the code to please. I tested it on some dummy files and it worked ok.

  5. #5
    Registered User
    Join Date
    04-24-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro Multiple excel files into one workbook as separate sheets

    Sub macro_1()
    Dim fname, wb1
    Set wb1 = ActiveWorkbook
    fname = Dir("U:\Data Role\SAR Reports\*.xl*")
    Do Until fname = ""
    With Workbooks.Open("U:\Data Role\SAR Reports\" & fname)
    .Sheets(1).Copy wb1.Sheets(1)
    ActiveSheet.Name = .Name
    .Close
    End With
    fname = Dir()
    Loop
    End Sub

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro Multiple excel files into one workbook as separate sheets

    Looks ok, you could try:
    Please Login or Register  to view this content.
    but I'm not sure that would work. What type of files are in that folder?

  7. #7
    Registered User
    Join Date
    04-24-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro Multiple excel files into one workbook as separate sheets

    Just xls. files

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro Multiple excel files into one workbook as separate sheets

    Afraid I can't really replicate the problem then, you could try this instead to see if it works any better:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-24-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro Multiple excel files into one workbook as separate sheets

    Thanks again for your help i can use a couple of these bits but am going to keep trying to get this to work

+ 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] Import multiple csv files into current workbook as separate sheets
    By santosh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-31-2013, 04:19 AM
  2. [SOLVED] workbook sheets into separate files
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 07:05 AM
  3. [SOLVED] workbook sheets into separate files
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  4. [SOLVED] workbook sheets into separate files
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  5. [SOLVED] workbook sheets into separate files
    By markx in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

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