• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Way to apply one code for all files

Hi,

Do you have any way to apply one code for all excel files in one folder.
Let say, i have one script and I want to run that script for each file in one folder.
As I am very basic of VBA, i need to open one file and past VBA code and run it.
If there are 100 files, i might need to do it 100 times. That's why i want to know if you can help.

Thanks,
Chanthan
 
Kim

There is plenty of code on the internet to do what you want

You basically loop through all the files in a directory
Open each file one at a time
Do what you want with that file
Close the file
Repeat

You don't copy the code into the file
you access the now open file using variables to define the Workbooks name and worksheets if required

have a look for example at:
https://www.mrexcel.com/forum/excel...-file-run-code-close-save-open-next-file.html
or
https://www.mrexcel.com/forum/excel-questions/559746-macro-open-all-files-folder.html
 
Back
Top