Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion merging exxcel files
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bernie Deitrick  
View profile  
 More options Mar 13 2001, 8:28 am
Newsgroups: microsoft.public.excel.worksheet.functions
From: Bernie Deitrick <dei...@consumer.org>
Date: Tue, 13 Mar 2001 08:21:01 -0500
Local: Tues, Mar 13 2001 8:21 am
Subject: Re: merging exxcel files
Mark,

Here is a macro that will merge all sheets of all files in a single folder
into one workbook.  If you want all the data on one, worksheet, then run the
second macro, which will copy the block of cells that includes A1 onto a
single sheet (the assumption being that the data is in a database starting in
A1 and with no blank rows or columns).

HTH,
Bernie

Sub ConsolidateAllSheetsIntoOneSpreadSheet()
Dim mySht As Worksheet
With Application.FileSearch
    .NewSearch
    'Change this to your directory
    .LookIn = "C:\Excel"
    .SearchSubFolders = False
    .FileType = msoFileTypeExcelWorkbooks
    If .Execute() > 0 Then
        For i = 1 To .FoundFiles.Count
            OpenIt = MsgBox("File: " & .FoundFiles(i) & Chr(13) & _
            "Do you want to include this?", vbYesNo)
            If OpenIt = vbYes Then
                Workbooks.Open .FoundFiles(i)
                For Each mySht In ActiveWorkbook.Worksheets
                    mySht.Name = ActiveWorkbook.Name & "- " & mySht.Name
                    mySht.Select (False)
                Next mySht
                ActiveWindow.SelectedSheets.Move After:=ThisWorkbook.Sheets(1)

            End If
        Next i
        Else: MsgBox "There were no files found."
    End If

End With

End Sub

Sub ConsolidateFirstSheetIntoOneSheet()

With Application.FileSearch
    .NewSearch
    'Change this to your directory
    .LookIn = "C:\Excel"
    .SearchSubFolders = False
    .FileType = msoFileTypeExcelWorkbooks
    If .Execute() > 0 Then
    Set Basebook = Workbooks.Open(.FoundFiles(1))
        For i = 2 To .FoundFiles.Count
            Set myBook = Workbooks.Open(.FoundFiles(i))
            Range("A1").CurrentRegion.Copy
Basebook.Worksheets(1).Range("a1").End(xlDown).Offset(1, 0)
            myBook.Close
         Next i
        Basebook.SaveAs Application.GetSaveAsFilename("Consolidated file.xls")

    End If
End With

End Sub

mark s wrote:
> Is it possible to merge an n number of excel files into one excel file. So
> we can manipulate all the data in just one single file.

> Thank you,

> m_13...@hotmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.