The code above can easily be adapted with the use of wildcard characters. 'Insert the actions to be performed on each file 'This example will print the file name to the immediate window 'Loop through all files in a folder Dim fileName As VariantįileName = Dir("C:\Users\marks\Documents\") Using the Dir Function – Method #1 Sub LoopAllFilesInAFolder() Check out the other VBA Code Snippets to see what else could be achieved. But it is easy enough to change the code to make it more complex and fit with your specific circumstances. The example we are looking will print the file name to the immediate window. Looping through all the files in a folder