+ Reply to Thread
Results 1 to 11 of 11

Loop for Folder count

  1. #1
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Loop for Folder count

    Hello Friends,

    I have a "Main" Folder. In this folder there are sub Folders i.e. 1, 2, 3, 4, 5,.......
    in each sub folders there are excel files which i want to open and save as a challen No. which is fix sheet1>range("A1").value of each excel file

    i just want to know how can i set the loop for each sub folders that i can open the excel file

    Please suggest me

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Loop for Folder count

    Hi there,

    Try this where the full path (i.e. directory and filename) for each Excel file is returned to a message box (adapt to suit):

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Loop for Folder count

    Hello Trebor76

    How would i open each excel from sub folders??
    i tried your code like this
    Please Login or Register  to view this content.
    Pls suggest me

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Loop for Folder count

    Your code works for me

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

    Re: Loop for Folder count

    This should give you some ideas on how to loop through subforlders:

    Please Login or Register  to view this content.
    abousetta
    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.

  6. #6
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Loop for Folder count

    No Friends,
    I can't get the idea. its not working
    above Trebor76 solution looking fine but not working

    Please suggest

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Loop for Folder count

    I can't suggest anything as it works for me? If you use this statement...

    Please Login or Register  to view this content.
    ...does it return the full path (directory and filename) of each file to be opened?

    Robert

  8. #8
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Loop for Folder count

    Hello Trebor76

    I seen all the way but not working
    here i attached sample file situation which want
    Please find the attached file
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Loop for Folder count

    It's because all the files have the same name - you can't have this in the same session of Excel.

    Change the file names (inclusing the file from where you're running the code) and then see how this slightly amended code goes:

    Please Login or Register  to view this content.
    Robert

  10. #10
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Loop for Folder count

    hello Trebor76
    there are same file name thats why we make subfolders
    and i also try to change the file name and then run your code but problem is same

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Loop for Folder count

    The following includes an error trap routine - see if it sheds any more insight as to what is going wrong:

    Please Login or Register  to view this content.
    You should also unselect the all cells option on Sheet1 of the main workbook.

    Robert

+ 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