+ Reply to Thread
Results 1 to 4 of 4

Loop Code to extract information from all files in a folder to a mastersheet

  1. #1
    Registered User
    Join Date
    01-20-2017
    Location
    Philippine
    MS-Off Ver
    2016
    Posts
    15

    Loop Code to extract information from all files in a folder to a mastersheet

    Hello I am new to VBA. I am a nurse so I don't know most of the proper jargons to use so please bear with me.

    I am currently working on a macro that will extract all encoded information from all files in the specified folder to my mastersheet.
    The code I made was successful. However, I noticed that when my folder is located to D:\, all newly added files in my folder were not extracted unless if I move the folder to another directory (e.g. to C:\). But if I place the folder in C:\ directory and add new files, it works perfectly. Here is my code so you may help me.

    PS: May I also ask if anyone can give me a code to rename the files that I already extracted? Just to append the word "Extracted" after their file names (e.g. from PHP.Jeff.xlsm -> PHP.Jeff(Extracted).xlsm).

    TYIA.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Loop Code to extract information from all files in a folder to a mastersheet

    A quick look suggests that this If statement may be the problem..
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-20-2017
    Location
    Philippine
    MS-Off Ver
    2016
    Posts
    15

    Re: Loop Code to extract information from all files in a folder to a mastersheet

    Quote Originally Posted by dangelor View Post
    A quick look suggests that this If statement may be the problem..
    Please Login or Register  to view this content.
    Hi dangelor, yes this statement is the one causing the problem. My masterfile starts with a letter "x" so it will be placed last in this list so this code will works. However if I add new files. Even if their first letter starts the same with my previous files. Excel always identify the new one as the last files, so before the code executes in these files, the macro already ended. Refresh does not work. It might appear in order if we view them through windows explorer, but in the excel itself, its not yet reorganized. The way to reorganize it is only by placing the whole folder in C:\ directory and run the macro.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Loop Code to extract information from all files in a folder to a mastersheet

    Try replacing
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

+ 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: 0
    Last Post: 05-24-2016, 12:32 PM
  2. [SOLVED] Choose a folder and loop through all files in the chosen folder
    By smartbuyer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-10-2016, 11:19 PM
  3. [SOLVED] Loop Through Folder, Create Emails with Sub Folder Names in Subject, Attach files in sub
    By Rschwar23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2015, 10:06 AM
  4. loop through all files in a folder and run code to unmerge and shift
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2015, 05:02 PM
  5. code to loop through all .docx files in folder
    By rs1aj in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-12-2015, 04:41 PM
  6. Replies: 12
    Last Post: 03-09-2015, 05:52 PM
  7. Replies: 3
    Last Post: 05-28-2012, 12:42 PM

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