1 Reply Latest reply: Oct 22, 2017 9:01 PM by Ryan King-Thornburg RSS

    How do I loop through all files in a folder in a macro?

    Griffin Neil

      Hi,

       

      I have a macro that I want to run for every file in a particular folder.

       

      i.e. At the moment I have

       

      Sub Macro ()

           (Macro code)

      End Sub

       

      I want something along the lines of:

       

      Sub Macro ()

           Set folder = 'C:\TEMP\'

           For each file in folder

                (Macro code)

           Next file

      End Sub

       

      What's the correct code I should be putting in to get it doing the rest of my code for each file in the folder?

       

      Thanks,

       

      Neil