Write 10 excel for loop

2 views (last 30 days)
Jason on 4 Mar 2016
Commented: Jason on 4 Mar 2016
Now I have one original.xlsx, I want to write Data in Sheet1 from E1.
How do I write 10 different Data{#} into Original.xlsx as different excel name, all in Sheet1 from E1.
for i=1:10
Jason on 4 Mar 2016
I want to have 10 different output excel file. e.g., first one save as 'January.xlsx', second on save as 'February.xlsx', ... All go into E1. Thank you in advance.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 4 Mar 2016
filenames = {'January.xlsx', 'February.xlsx', 'Cheezburger.xlsx', 'Durango95.xlsx', 'EschewObfuscation.xlsx', ....};
for i=1:10
xlswrite(filenames{i}, Data{i}, 'Sheet1','E1');
Jason on 4 Mar 2016
I think you answered my questions. I will check the code after I finished the Friday party. Thank you in advance

Sign in to comment.

More Answers (1)

Joachim Schlosser
Joachim Schlosser on 4 Mar 2016
You can write the whole cell array at once. See the cell array example in the online help: http://www.mathworks.com/help/releases/R2015b/matlab/ref/xlswrite.html
If you are asking about the for loop because you first are calculating each cell before writing, I'd advise to export to Excel in a separate step after the loop for performance reasons.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!