+ Reply to Thread
Results 1 to 21 of 21

Get Data From Entire Directory

  1. #1
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Get Data From Entire Directory

    I can't seem to find a solution that works, so I don't have an example or starting point, so I'll try to explain as best I can

    I need the data from certain cells in every workbook in "C:\Housing Data" All workbooks have unique names, and are in subfolders.

    I'd like column "A" to be filled with the name of each workbook,
    column "B" to be filled with the data from cell "H26",
    column "C" to be filled with the data from cell "F32",
    column "D" to be filled with the data from cell "M32".

    Example:
    [
    550 W. Evergreen Terrace 60625 5/15 6/2
    202 N. Pineapple Dr. 60625 3/12 8/14
    18 W. Stapler Ave. 60339 3/13 3/15

    Each row would be from a different workbook.
    I've tried multiple solutions, but I keep running into a file system object error.

    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: Get Data From Entire Directory

    Hello SoothSailor,

    Do you want to find files in subfolders of "C:\Housing Data" and the in the subfolders of subfolders, etc?
    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
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    Correct. Thank you.

  4. #4
    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: Get Data From Entire Directory

    Hello SoothSailor,

    What headers should I use for the columns "B:D" ?

  5. #5
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    "Zip Code", "Date In", "Date out" work for me. Thank you very much.

  6. #6
    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: Get Data From Entire Directory

    Hello SoothSailor,

    One more question. Do these workbooks have only a single worksheet or does each worksheet have data in the same place?

  7. #7
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    Hi Leith,
    Each workbook has multiple worksheets, but all the data I need will be in the sheet "FORM"
    (So, for example the "Zip Code" would be in

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    And yes, all data would be in the same place in each workbook.

  9. #9
    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: Get Data From Entire Directory

    Hello SoothSailor,

    Thanks for the clarification. I put a workbook together that you can use. Hopefully with little modification.

  10. #10
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    Thank you! You're very kind. Did you attach it?

  11. #11
    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: Get Data From Entire Directory

    Hello SoothSailor,

    Sorry, that was a typo. It should have been "I will put together a workbook."

    I don;t have one I can modify in my files.

  12. #12
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    Gotcha. Thank you so much!

  13. #13
    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: Get Data From Entire Directory

    Hello SoothSailor,

    Here is a test workbook. This will open the folder "C:\Housing" and search all folders and subfolders for xls, xlsx, and xlsm type workbooks.

    There is a button on "Sheet1" to run the macro.

    Test it out and let me know the results.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    04-09-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    176

    Re: Get Data From Entire Directory

    Hi Leith Ross,
    thanks for your valuable code. is it possibile to change your code just to extract data from all the files in subfolders inside a folders irrespective of columns.
    Thanks in advance

  15. #15
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    Hi Leith,
    Unfortunately, when I click "Run", nothing happens. I went into the VBA editor, copied the exact file path that is on my computer and ran it from there, and still nothing happened. I looked through the code, and I couldn't find a reason for it not to work, but I don't know a whole lot about VBA. (by the way, my version of Excel is Excel 360 Pro Plus)

  16. #16
    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: Get Data From Entire Directory

    Hello genetist,

    Can you provide an example of how the output should appear?

  17. #17
    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: Get Data From Entire Directory

    Hello SoothSailor,

    If you are not receiving error messages and there is no output then there were no xls, xlsx, or xlsm files found in the folder or it's subfolders.

  18. #18
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    OH, I'll add .xlsb to the filter. They're binary files. Thank you.

  19. #19
    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: Get Data From Entire Directory

    Hello SoothSailor,

    That should give you some results. I added the most workbook types in the filter. Adding xlsb did cross my mind, but not many look for that type of file. Let me know the results.

  20. #20
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Get Data From Entire Directory

    It works! Thank you very much, cut down my work by a few hours.

  21. #21
    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: Get Data From Entire Directory

    Hello SoothSailor,

    Excellent, glad I could help save you some time.

+ 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. Replies: 1
    Last Post: 07-28-2014, 05:18 PM
  2. Replies: 0
    Last Post: 09-05-2013, 10:00 AM
  3. Contunue Search through entire workbook and directory
    By sport030 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2013, 11:57 AM
  4. Need VBA code to search file in directory and sub-directory and show result
    By johnchencanada in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2012, 11:13 PM
  5. Reading in the files in a directory into an array, directory chosen by user
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-18-2011, 12:52 PM

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