+ Reply to Thread
Results 1 to 4 of 4

Combining Multiple Excel Workbooks Into One

  1. #1
    Registered User
    Join Date
    07-06-2011
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    20

    Question Combining Multiple Excel Workbooks Into One

    Is there a way in VBA to select a folder with ~20 different Excel Workbooks. Have a loop perform the same task to each workbook in the folder and combine them into one excel workbook?

    As of right now I have this code:

    [code]

    Sub MastercurveCreater()

    Workbooks.Add

    ActiveWorkbook.SaveAs "N:\******\ MasterCurve Start\" & "InitialSave" & ".xlsx"

    SelectData.Show

    '
    ' DataSelection Macro
    '
    Range("K1").Select
    Range(Selection, Selection.End(xlDown)).Select
    ActiveWindow.SmallScroll Down:=-30
    Range("K1:K68,N1").Select
    Range("N1").Activate
    Range(Selection, Selection.End(xlDown)).Select
    Range("K1:K68,N1:P68").Select
    Range("N1").Activate

    Selection.Copy

    Windows("InitialSave.xlsx").Activate

    Range("A1").Select

    ActiveSheet.Paste

    SaveWorkbook.Show

    'You can use this to delete all xlsx files in the folder Test
    On Error Resume Next
    Kill "N:\MATDEV\MasterCurve Start\" & "InitialSave" & ".xlsx"
    On Error GoTo 0


    End Sub

    [code\]

    It takes all the data from one spreadsheet to which I specify and copies and paste it into another blank worksheet.

    I would like to do this for all the worksheets in the folder, but am unsure of how to go about doing it.

    Any help would be appreciated.

    Thanks a lot!
    Last edited by ZEvans12; 07-08-2011 at 08:30 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining Multiple Excel Workbooks Into One

    'WORKBOOKS TO 1 SHEET STACKED
    Here's a macro for collecting data from all files in a specific folder.The parts of the code that need to be edited are colored to draw your attention.

    Based on your sample code above, I'd think the "customization" section would look something like:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 07-06-2011 at 05:45 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-06-2011
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Combining Multiple Excel Workbooks Into One

    Worked perfectly.. I changed around a few things here and there to make it smoother, but this is exactly what I needed.

    Thank you.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining Multiple Excel Workbooks Into One

    Awesome...

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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