+ Reply to Thread
Results 1 to 2 of 2

Loop through each folder copy values from range in file1 to named range in file2

  1. #1
    Registered User
    Join Date
    08-26-2013
    Location
    Missouri
    MS-Off Ver
    Excel 2007
    Posts
    10

    Loop through each folder copy values from range in file1 to named range in file2

    I have a list of Folders in a directory

    Folder1
    Folder2
    Folder3
    Folder4
    Folder5
    ....... Continues for a total of 20 folders


    Each folder contains 2 files
    Example Start::
    In folder1 the files are called
    Folder1 - Q4(RawData).xls
    Folder1 - Q4(Graphs).xlsx

    Folder2 the files are called
    Folder2 - Q4(RawData).xls
    Folder2 - Q4(Graphs).xlsx
    Example End


    For each Subfolder in directory do the following:
    1. open ????? - Q4(RawData).xls
    Sheet name I - Copy Range("A3:C15") -to- range IChartdata in ????? - Q4(Graphs).xlsx
    Sheet name L - Copy Range("A3:G15") -to- range LChartdata in ????? - Q4(Graphs).xlsx
    Sheet name R - Copy Range("A3:I15") -to- range RChartdata in ????? - Q4(Graphs).xlsx
    Sheet name M - Copy Range("A3:H15") -to- range MChartdata in ????? - Q4(Graphs).xlsx

    2. Goto next folder and do step 1


    I recorded the following code but I need help on make this work for all folders.


    Thanks
    Steve

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Loop through each folder copy values from range in file1 to named range in file2

    Hardly the most efficient of codes but should work based on you file description. You need to change the sPath to the main folder where you you have your subfolders.

    Macro loops from 1 to 20 to extract data from all Q4(RawData).xls files and paste it to the Q4(Graphs).xlsx file.

    Suggest that you have a backup of your original data before you test this.

    Please Login or Register  to view this content.
    Alf

+ 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 folder, copy range, Paste range to original workbook
    By knevil in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-09-2016, 05:33 PM
  2. [SOLVED] Vba Macro to save File2 if File1 saved
    By abbasabdulla in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-02-2014, 11:09 AM
  3. Copy data from file1.xls to file2.xls and convert do html file
    By alban01 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-13-2013, 10:39 AM
  4. Loop through File1 with File2 and show differences in third file
    By sravanthi009 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2011, 09:03 AM
  5. Copy Data From File1 to File2
    By simonstaton in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2011, 06:19 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