Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
Maria Ester Etayo Lopez
Maria Ester Etayo Lopez el 23 de Oct. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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.

Respuestas (1)

Arvind Narayanan
Arvind Narayanan el 26 de Oct. de 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.

Community Treasure Hunt

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

Start Hunting!

Translated by