+ Reply to Thread
Results 1 to 4 of 4

Combine 50 excel file into one new file

Hybrid View

tajulit Combine 50 excel file into... 10-27-2015, 11:12 AM
JOHN H. DAVIS Re: Combine 50 excel file... 10-27-2015, 11:45 AM
tajulit Re: Combine 50 excel file... 10-27-2015, 11:57 AM
JOHN H. DAVIS Re: Combine 50 excel file... 10-27-2015, 01:31 PM
  1. #1
    Registered User
    Join Date
    10-26-2015
    Location
    Bangladesh
    MS-Off Ver
    2007
    Posts
    25

    Combine 50 excel file into one new file

    Hi All,

    I have 50 Excel file in One folder. Every file has same column such A-E but rows are different. Some have 1000 rows data & another may more or less rows.
    I want combine all files data into one file in same folder.


    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Combine 50 excel file into one new file

    Here's one I use. Hope it will be useful too you as well.

    Sub tajulit()
    'I create a workbook called Combined
    'I open all the workbooks I want to combine in the order I want, in your case all 50
    Dim wbk As Workbook, wbkC As Workbook
    Set wbkC = Workbooks("Combined.xlsx")
    For Each wbk In Workbooks
        If wbk.Name <> wbkC.Name Then
            With wbk
                .Sheets("Sheet1").UsedRange.Offset(1).Copy wbkC.Sheets("Sheet1").Range("A" & Rows.Count).End(3)(2)
            End With
        End If
    Next wbk
    End Sub

  3. #3
    Registered User
    Join Date
    10-26-2015
    Location
    Bangladesh
    MS-Off Ver
    2007
    Posts
    25

    Re: Combine 50 excel file into one new file

    Quote Originally Posted by JOHN H. DAVIS View Post
    Here's one I use. Hope it will be useful too you as well.

    Sub tajulit()
    'I create a workbook called Combined
    'I open all the workbooks I want to combine in the order I want, in your case all 50
    Dim wbk As Workbook, wbkC As Workbook
    Set wbkC = Workbooks("Combined.xlsx")
    For Each wbk In Workbooks
        If wbk.Name <> wbkC.Name Then
            With wbk
                .Sheets("Sheet1").UsedRange.Offset(1).Copy wbkC.Sheets("Sheet1").Range("A" & Rows.Count).End(3)(2)
            End With
        End If
    Next wbk
    End Sub

    Hi JOHN H. DAVIS,
    Thanks for your code. Its great. I am learning VBA.
    Is there any way complete this task without opening excel files myself?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Combine 50 excel file into one new file

    Try:

    Sub tajulitz()
    Dim CurFile As String, DirLoc As String
    Dim DestWb As Workbook
    Dim ws As Worksheet
    
    DirLoc = ThisWorkbook.Path & "\tst\" 'Enter your file folder location here
    CurFile = Dir(DirLoc & "*.xlsx")
    
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    
    Set DestWb = Workbooks("Combined.xlsx")
    
    Do While CurFile <> vbNullString
        Dim OrigWb As Workbook
        Set OrigWb = Workbooks.Open(filename:=DirLoc & CurFile, ReadOnly:=True)
        Set ws = OrigWb.Sheets("Sheet1")
    
            ws.UsedRange.Offset(1).Copy DestWb.Sheets("Sheet1").Range("A" & Rows.Count).End(3)(2)
       
        OrigWb.Close SaveChanges:=False
        CurFile = Dir
    Loop
    
    
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    
    Set DestWb = Nothing
    
    End Sub

+ 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] Macro to combine a Text File & Excel file into one Separate workbook
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2014, 03:42 PM
  2. Macro to combine a Text File & Excel file into one Separate workbook
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2014, 03:23 AM
  3. Replies: 0
    Last Post: 08-28-2012, 03:51 PM
  4. Creating a .txt file extracting information from a Excel file saving as .resx file
    By AbdallahHajbed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2012, 09:00 AM
  5. File Combine 123 to Excel
    By chunkylover57 in forum Excel General
    Replies: 1
    Last Post: 09-26-2006, 07:14 PM
  6. Replies: 1
    Last Post: 12-30-2005, 05:35 PM
  7. Replies: 0
    Last Post: 12-29-2005, 01:10 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