xlsread multiple files from multiple folders
2 views (last 30 days)
Show older comments
I want to xlsread and xlswrite every .xls file within each folder from a group of folders (58 total folders).
This code works for one file:
f = dir('Y:\Projects\Round\test.xls')
sheet = 'Logic';
[num,str] = xlsread(f,sheet,'D5:D5');
n = 675;
if str == "Test"
xlRange = 'D1';
xlswrite(f,n,sheet,'D7:D7')
end
This is semi-finished code where I think it would work for one folder, but I want it to loop through every folder within a folder.
files = dir('Y:\Projects\Round\*.xls');
sheet = 'Logic';
nFiles = length(files);
for i = 1:nFiles
fName = files(i).name
[num,str] = xlsread(fName,sheet,'D5:D5');
sttd = 675;
if str == "Teset"
xlRange = 'D1';
xlswrite(fName,sttd,sheet,'D7:D7')
end
end
Problem with this code is that when I get the name of the file and put it into xlsread, it assumes I am working in my current folder and not somewhere else. instead of fName I need the whole directory.
0 Comments
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!