Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Maria Ester Etayo Lopez
Maria Ester Etayo Lopez le 23 Oct 2017
Clôturé : MATLAB Answer Bot le 20 Août 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.

Réponses (1)

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

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by