+ Reply to Thread
Results 1 to 14 of 14

VBA to get data from multiple files to one s/sheet - occasional coder stuck !

  1. #1
    Registered User
    Join Date
    02-01-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2007 Access 2007
    Posts
    8

    VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    Hi, I haven't written in VB for 2.5 years, and have spent 2 days trying to get a big batch process written - with limited time.

    I have a couple of hundred excel files come in each month, from which I need to strip essential data, and then compile on one spreadsheet, in consecutive rows.

    I have had a couple of big wins already - in terms of automating the process of getting the files onto my directory from multiple outlook emails, and then automating the reformatting of the data in each file; (happy to share this !).

    Each individual file contains similar data in A2:FA4 - three rows.

    The Master file will therefore contain around six hundred lines - not too onerous I would have thought.

    However I have been ploughing through forums, but haven't found anything yet that works for me yet - haven't even got off the ground with this one - I don't know if it's my limited syntax with vb or what.

    Any ideas / examples will be very gratefully received !
    (Please be gentle, I was astonished how much of the basics I had to revise to get this far.)

    Thank you !
    Last edited by OutOfShape; 02-04-2011 at 12:39 PM. Reason: All done very helpful

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    First advice would be to search the Forum. I've posted codeto do this several times, see this
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-01-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2007 Access 2007
    Posts
    8

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    Thank you RoyUK, will be checking this out today.

  4. #4
    Registered User
    Join Date
    02-01-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2007 Access 2007
    Posts
    8

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    Am Getting RunTime Error 76 related to:
    ChDir sPath

  5. #5
    Registered User
    Join Date
    02-01-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2007 Access 2007
    Posts
    8

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    RoyUK
    Ignore that, fixed it - thank you so much.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  7. #7
    Registered User
    Join Date
    02-01-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2007 Access 2007
    Posts
    8

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    Apologies RoyUK - I cannot seem to get the data I want captured - have tried re-coding, but ended up in a total mess... I just need to change the range (this is pretty embarassing - I have gone thorugh forum but drawn a blank..)

    My source data:
    1) Never contains headers
    2) Will always contain three rows that I need to bring over - B2:FA4
    3) In the master file I need to keep column a and row 1 clear, so "paste" from B2 downwards.

    Any assistance gratefully received !

    Thanks again
    Attached Files Attached Files

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    In the example you want to copy that data to a master workbook?

  9. #9
    Registered User
    Join Date
    02-01-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2007 Access 2007
    Posts
    8

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    That's correct - My example is one of 300 or so files that I want to append to a master file each month. Thank you.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    Try this. Paste the code into the master workbook

    Please Login or Register  to view this content.

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    If you put this macro in the 'master' workbook this will suffice:

    Please Login or Register  to view this content.
    Adapt the foldername to your situation.
    Adapt the file extension if necessary.
    This macro is rather harmless because it can't destroy the original workbooks; the method workbooks.Add opens copies of the workbooks.
    Last edited by snb; 02-03-2011 at 06:46 AM.



  12. #12
    Registered User
    Join Date
    02-01-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2007 Access 2007
    Posts
    8

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    @RoyUK
    Can't thank you enough, that's "phase 3" of my job redesign project for this week completed - on a Friday afternoon also ! I have just reduced two days' work, for which we no longer have capacity, to what I reckon will be about an hour. Seriously, thank you.

    @snb - thank you also for your advice, also appreciated.

    Cheers.

  13. #13
    Registered User
    Join Date
    07-09-2012
    Location
    us
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    Quote Originally Posted by OutOfShape View Post
    Am Getting RunTime Error 76 related to:
    ChDir sPath
    Hithere,

    How did you fixthe error?

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

    Re: VBA to get data from multiple files to one s/sheet - occasional coder stuck !

    Hello ayeshadatta, and welcome to the forum. Unfortunately you've inadvertently broken one of the forum rules. Please read the following:

    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)

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