+ Reply to Thread
Results 1 to 9 of 9

Want a Macro in Excel to Compile data from Several individual files into a separate Master

  1. #1
    Registered User
    Join Date
    08-31-2012
    Location
    Japan
    MS-Off Ver
    Excel 2010
    Posts
    3

    Smile Want a Macro in Excel to Compile data from Several individual files into a separate Master

    Dear all,

    I just started using macro but i went through many threads and wanted to find a post for this exact problem, i couldn't

    i have about 262 ".xls" files in a directory. These files have only one sheet that is named randomly.

    i want values in column D of each of these files to compiled in successive columns of a master file. the data is year around temperature so the data range is D1:D365

    it would be even better if there could be a column header with the file name or sheet name on it.

    I would thank you in advance for your help

  2. #2
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: Want a Macro in Excel to Compile data from Several individual files into a separate Ma

    Hi Uttam,
    Welcome to the forum!

    A just quick question : In master file, Where the data has to be stored ?
    and where the column header you want to display ???

    Thanks
    A

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Want a Macro in Excel to Compile data from Several individual files into a separate Ma

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    08-31-2012
    Location
    Japan
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Want a Macro in Excel to Compile data from Several individual files into a separate Ma

    Dear mmmarks,

    I want the column D from the source files to be copied to the sheet1 of the master file in successive columns.
    and for the identification of the source files i wanted column header to be source file's file or sheet name if possible

    ---------- Post added at 09:17 PM ---------- Previous post was at 09:12 PM ----------

    Dear arlu1201

    thank you for the elaborate procedure and the codes, i made the macro to run by making adjustment to 'mypath',
    the macro runs smoothly but there might be some glitch coz the master file is blank every time.
    while the macro is running, i can see that it is copying all the content of the source file to the master and then again being replaced by next copy and in the end all is blank.
    Last edited by Cutter; 09-02-2012 at 01:22 PM. Reason: Removed whole post quote

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Want a Macro in Excel to Compile data from Several individual files into a separate Ma

    Do you have a sample file that you can upload?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

  6. #6
    Registered User
    Join Date
    08-31-2012
    Location
    Japan
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Want a Macro in Excel to Compile data from Several individual files into a separate Ma

    Dear arlu1201

    i have attached one of the source files that i am trying to copy into the master file
    the data is of one of the record stations named "DS010420.00" and the filename is "DS010420.00.xls"
    i wanted to copy the data in column D of the file and several other similar files to one master xls.
    please feel free to ask me anything more in this regard and i appreciate your help.
    Thank you.
    Attached Files Attached Files
    Last edited by Cutter; 09-02-2012 at 01:21 PM. Reason: Removed whole post quote

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Want a Macro in Excel to Compile data from Several individual files into a separate Ma

    Did you put the macro in the master file or in the source file?

    I am sorry if i didnt mention it earlier but the macro needs to go into your master file.

  8. #8
    Registered User
    Join Date
    10-18-2012
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Want a Macro in Excel to Compile data from Several individual files into a separate Ma

    I am looking for a similar macro, instead, I would like to pick the data from all the files in the folder and put it one after the other, i.e. a master list. There are Q number of columns that I want to stack. How would we modify the code you gave above for this situation?

    Thanks!

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Want a Macro in Excel to Compile data from Several individual files into a separate Ma

    Hello knixer, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and make the necessary change. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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