Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Merging Data from many workbooks in to one workbook

  1. #1
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14

    Merging Data from many workbooks in to one workbook

    Hi,

    I got a macro code to merge data from diffrent files into one workbook. Currently when we run the code every time it make a new workbook and fetch the files basis given path. I wants, instead of making a new file it should update an existing file (I will assigne the macro to a button), and it should start merging the data from sheet2, because sheet1 is reserve for my dashboard.

    Attached is the file with code.
    Code source: http://www.rondebruin.nl/fso.htm

    Thanks
    Rajesh
    Attached Files Attached Files

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Search for the code
    Code:
    Set BaseWks = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
    with
    Code:
        If ThisWorkbook.Worksheets.Count > 1 Then
            Set BaseWks = ThisWorkbook.Worksheets(2)
        Else
            Set BaseWks = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        End If
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14
    Hi, Implemented the below solution, while running the code getting dbug screen and highlighting the below line:

    Code:
    If Not sh Is Nothing Then
                    sh.Copy After:=BaseWks.Parent.Sheets(BaseWks.Parent.Sheets.Count)
    seems needs to make changes to this line as well.

    Thanks
    Rajesh

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    can you post the error description?

    Is it by any chance, this..

    Code:
    Excel cannot insert the sheets into the destination workbook, because it contains fewer rows and columns than the source workbook. To move or copy the data to the destination workbook, you can select the data, and then use the Copy and Paste commands to insert it into the sheets of another workbook.
    If yes, try using the attached Excel 2007-2010 file.
    Attached Files Attached Files
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  5. #5
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14
    This code is working fine . Let me implement this in the real sheet that i am working on. Will update the results.

    Thanks for the help.
    Rajesh

  6. #6
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14
    Hi, This code keeps adding sheets (makes dupilcate) , if i run it for more then one time. Is it possible to over write the exixting sheets. My scenario is - I have the source workbooks with unique names and i wants to update the destination file (the file with code) every time i run the code. On more thing while fetching the data if there is an excel 2003 file it only the name in the sheet same as the source file name , but if the file is a excel 2007, it shows sourcefilename.xlsx.

    Thanks
    Rajesh

  7. #7
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Replace my last piece of code with

    Code:
        Application.DisplayAlerts = False
        Do While ThisWorkbook.Worksheets.Count > 1
            ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Delete
        Loop
        Application.DisplayAlerts = True
        Set BaseWks = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  8. #8
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14
    Hi, I replaced the code, when you run the code it seems it is doing somthing ,but it is dosent add the data, it shows only one blank sheet.
    Is it possible fot you to implement in the file that i attached and send.

    Thanks
    Rajesh

  9. #9
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14
    Hi Experts, awaiting for your kind assistance.

    Thanks
    Rajesh

  10. #10
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Working on this now
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Split Workbook into Separate Workbooks VBA
    By Admin in forum Download Center
    Replies: 12
    Last Post: 08-08-2018, 09:33 PM
  2. Replies: 2
    Last Post: 05-28-2013, 05:32 PM
  3. Replies: 1
    Last Post: 05-09-2013, 08:56 AM
  4. Replies: 2
    Last Post: 12-19-2012, 08:28 AM
  5. Split Closed Workbook into Multiple Workbooks Using ADO
    By ramakrishnan in forum Excel Help
    Replies: 4
    Last Post: 10-02-2011, 08:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •