+ Reply to Thread
Results 1 to 3 of 3

VBA read all Excel files in a directory then parse through each

  1. #1
    Registered User
    Join Date
    10-26-2009
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    12

    VBA read all Excel files in a directory then parse through each

    Hello -


    I am needing a script in Excel that I can press a button and it will ask for a folder name, then read through all the XLS files in the folder one by one and step through the individual tabs writing a segment from each tab to another spreadsheet



    For example: I have 123.XLS, 456.XLS and 789.XLS all in one folder

    123.XLS

    Sheet1

    Sheet2

    Sheet3

    456.XLS

    SheetA

    SheetB

    789.XLS

    SheetX

    SheetY

    SheetZ



    MACRO/Script would reside in ABC.XLS in another folder so it is not read.



    I would like this script to first open 123.XLS, finding it has 3 sheets. I would for example to read A1 and place it back into ABC.XLS, then go to sheet2 and read A1 and place it back into ABC.XLS, then sheet3 and read A1 and place it back into ABC.XLS



    Then go to the next XLS file.



    I hope this makes sense.



    thanks.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA read all Excel files in a directory then parse through each

    Hello kpierce,

    Welcome to the Forum!

    This macro will let you choose the folder to copy from. Each "A1" value will be transferred to the active sheet starting with the next cell after the last entry in column "A".
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-07-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: VBA read all Excel files in a directory then parse through each

    Hi, thank you for this very useful code. Could you tell me how I would restrict the read to only specified worksheets in a workbook and also a specific range (A1:F1) as opposed to the single cell example in this code.

    Thanks

+ 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