Results 1 to 2 of 2
2003-11-10, 12:43 #1
- Join Date
- Aug 2002
- Tillicoultry, Clackmannanshire, Scotland
- Thanked 0 Times in 0 Posts
run a macro on a batch of files (Excel 2000 9.0.44
I have a macro in Excel to strip the column headers in an Excel file then save the file as a CSV or other format, this works well but my question is how can I get this macro to run on a batch of say 300 Excel files automatically without having to start it manually for each file?
2003-11-10, 13:42 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: run a macro on a batch of files (Excel 2000 9.0.44
If all 300 files are in one folder, and if they are the only workbooks in that folder, it is relatively easy. Say that your macro is called MyMacro and acts on the currently active workbook. It should save the csv file under a name that relates to that of the workbook, not under a generic name like Export.csv.
' Substitute appropriate folder name
Const strFolder As String = "C:Excel"
Dim strFile As String
strFile = Dir(strFolder & "*.xls")
Do While strFile <> ""
Workbooks.Open strFolder & strFile
' Process workbook; substitute actual macro name
strFile = Dir