+ Reply to Thread
Results 1 to 5 of 5

Macro to choose folder and cycle through all files

  1. #1
    Registered User
    Join Date
    06-20-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Macro to choose folder and cycle through all files

    Thanks in advance.

    I have a workbook that contains many control charts and currently it requires someone to open each file in a folder to enter all the data into the workbook using a hot-key'd macro. I'd like to be able to cut down the work involved and just have the user choose the folder so that a similar macro could copy all the data into the workbook where the macros already in place would be able to compile it.

    While I've seen may similar questions on this forum. This code http://www.excelforum.com/forum-rule...rum-rules.htmlappears to be what I believe I need,so I've altered it to my needs.


    I'm not sure why the code below will not work:

    Please Login or Register  to view this content.
    Last edited by Mr.Pinches; 07-08-2011 at 04:35 PM. Reason: [Solved]

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macro to choose folder and cycle through all files

    It is not working because you have:
    Please Login or Register  to view this content.

    But you have not given x a value. So you are saying
    Please Login or Register  to view this content.

    I cleaned up your code below and removed the For I = 1 to x, because I don't see the need for it. You are already looping through each file with "For Each myFile in MyFolder"
    Please Login or Register  to view this content.

    Also, I would change the task you perform with each sheet. The way it is now, you copy the entire Summary sheet and paste it into the Paste sheet... But then this gets repeated for each workbook. This means that, in effect, only the last workbook Summary sheet values will remain in the Paste sheet. Everything else gets overwritten with each loop.
    Last edited by Whizbang; 06-20-2011 at 04:02 PM.

  3. #3
    Registered User
    Join Date
    06-20-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Macro to choose folder and cycle through all files

    Thank you I'll go see if this works for me!!!

    Also to explain the 'paste' sheet:

    I already have a workbook that has a bunch of macros activated anytime the paste sheet is changed. So really that moves all the data into other tabs.

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

    Re: Macro to choose folder and cycle through all files

    Please Login or Register  to view this content.
    Last edited by snb; 06-22-2011 at 03:53 PM.



  5. #5
    Registered User
    Join Date
    06-20-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Macro to choose folder and cycle through all files

    Thank you Whiz bang, it worked with some adjustments to my strategy.

    Cheers!

+ 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