+ Reply to Thread
Results 1 to 5 of 5

Combine files in VBA

  1. #1
    Registered User
    Join Date
    03-17-2014
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    4

    Combine files in VBA

    I read some threads, and write down this code. The purpose is for combining excel files into one.
    For example, I have 10 data files. All of them are in the same format with 2 sheets. I want to use the VBA code to combine them into one excel file.
    After testing, lots of data are missing. I use F8 to check it step by step, and found out that the new files data will replace the old one, etc.

    What should this code be amended for my purpose?
    Please Login or Register  to view this content.

    Thank you!!
    Last edited by Andy910104; 03-18-2014 at 12:11 PM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Combine files in VBA

    You must find the first empty cell in column A. This is the position you want to put your copied data.
    Change those 2 lines of codes.
    Please Login or Register  to view this content.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    01-19-2014
    Location
    Hong Kong
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Combine files in VBA

    Quote Originally Posted by p24leclerc View Post
    You must find the first empty cell in column A. This is the position you want to put your copied data.
    Change those 2 lines of codes.
    Please Login or Register  to view this content.
    I understand the code, but VBA turns out with application-defined or object-definded error. Is there anything i missing?

  4. #4
    Registered User
    Join Date
    03-17-2014
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Combine files in VBA

    Quote Originally Posted by p24leclerc View Post
    You must find the first empty cell in column A. This is the position you want to put your copied data.
    Change those 2 lines of codes.
    Please Login or Register  to view this content.

    I got the same problem, application-defined or object-definded error.
    Is it meaning that VBA cannot define Range("A2").End(xlDown).Offset(1).Resize()?
    Then, can I cut down this statement into two to make this work?

  5. #5
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Combine files in VBA

    Strange, it works well on my computer which also runs Excel 2010. Are you sure the error is on this line of code? If you click on Debug, which line is highlighted?
    You can try this:
    Please Login or Register  to view this content.

+ 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] how to combine hundreds of files into one
    By margosa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-08-2013, 01:07 PM
  2. Combine all Files into 1
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2009, 12:56 PM
  3. Combine files
    By TinaK819 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-30-2009, 03:07 PM
  4. Combine csv files
    By RevJeff in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2006, 04:55 PM
  5. [SOLVED] combine two files
    By Charles in forum Excel General
    Replies: 1
    Last Post: 08-09-2005, 05:05 PM

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