Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Add a value to an already fulfilled cell in an excel file

1 Ansicht (letzte 30 Tage)
Maria Ester Etayo Lopez
Maria Ester Etayo Lopez am 23 Okt. 2017
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hello,
I would like to know how I can add a given value (+50) to a cell which already contains an initial value in several excel files at once (same value in same cell for all excel files) using a loop.
Thank you in advance.

Antworten (1)

Arvind Narayanan
Arvind Narayanan am 26 Okt. 2017
Hi,
You can store the names of all the Excel files in a cell array and use the xlswrite command in a for loop that iterates through the contents of the cell array and writes into each Excel file. A sample of the code snippet would be as follows:
if true
files = {'blank1.xlsx','blank2.xlsx','blank3.xlsx','blank4.xlsx'}; %names of the Excel files
s=size(files);
for i=1:1:s(2)
filename=files{i};
xlswrite(filename,200,'Sheet1','B4'); %Writing into cell B4
end
end
In the above snippet, I am iterating through the cell array that contains the filenames. In each iteration, I use the xlswrite function to write into the B4 cell of the Excel sheet. Please refer to the documentation of xlswrite command to understand the Name-Value pairs of arguments.
Hope this helps.

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by