Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

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

1 Reply
milkyryan
Partner - Contributor II
Partner - Contributor II

Hi Griffin,

Not sure if you're still working on this but I found Michael Anthony's solution on the below thread to be very helpful.

search for filenames in a directory within a macro

I used this loop to convert XML to Excel XLS format for all files in a folder, I trust you'll also find this to be very useful.

Thanks,

Ryan.