I have a folder with thousands of excel files containing municipal budget data. I am attempting to loop through each file, import specific cells of data, and merge them all into one single file. The code I have does this, unless there is an error in any of the excel files (e.g. missing the sheet of data I am importing). I would like to skip over the excel file if there is any error and continue with the import. I've tried using capture noisily, but it does not work. Any help is appreciated!
cd "C:\Data\Budgets"
clear
local allfiles: dir . files "*.xls"
foreach file of local allfiles {
preserve
import excel using `file', sheet("Budget Data") cellrange(A1:R9) clear
save temp, replace
restore
append using temp, force
}
-Mike
cd "C:\Data\Budgets"
clear
local allfiles: dir . files "*.xls"
foreach file of local allfiles {
preserve
import excel using `file', sheet("Budget Data") cellrange(A1:R9) clear
save temp, replace
restore
append using temp, force
}
-Mike
Comment