+ Reply to Thread
Results 1 to 8 of 8

Loop through files in folder

  1. #1
    Registered User
    Join Date
    04-01-2011
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    23

    Loop through files in folder

    Hello,

    So I am trying to loop through a large number of excel files in a folder. In each file, I want to find a maximum value from a selected range and add that maximum value in a column to a different workbook.

    I found a code which loops through files in a folder but I do not think I am using it correctly.

    It has been a while since I have used VBA so I am rusty.

    Here is the code

    Please Login or Register  to view this content.

    Any help would be much appreciated


    Best Regards,
    Daniel

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Loop through files in folder

    Daniel - what do you mean, is the code not working, or giving you unexpected results, or something else?

  3. #3
    Registered User
    Join Date
    04-01-2011
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Loop through files in folder

    So the code will first allow me to browse and select a folder, then once I select a folder I get a the message box. No data is written on the intended workbook.

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Loop through files in folder

    There's nothing in your code to write anything to a workbook. What should happen?

  5. #5
    Registered User
    Join Date
    04-01-2011
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Loop through files in folder

    Well this code,
    Please Login or Register  to view this content.
    was supposed to record the max value into the other workbook then go down one row for the next max value.

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Loop through files in folder

    My mistake, I missed that, but I'm surprised your code doesn't error as i starts off as zero. The +1 line should come first.

  7. #7
    Registered User
    Join Date
    04-01-2011
    Location
    North Carolina
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Loop through files in folder

    I figured it out!!! My files were not .xls but a different format. I changed to myExtension = "*.*" and the code works great. Thanks for the help Stephen

  8. #8
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Loop through files in folder

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

+ 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. Loop through files in a folder
    By paesu57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-12-2014, 09:24 AM
  2. Loop through all files in folder
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2013, 09:40 PM
  3. VBA Loop for a folder of all the files, Loop all the worksheet in each workbook
    By nanjingwoodworking in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2013, 07:20 PM
  4. Loop between 2 files in a folder
    By jharaldson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2013, 02:33 AM
  5. loop through all files in a folder except for one of them
    By masben in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2013, 10:23 AM

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