Read same cell in multiple excel files
Mostrar comentarios más antiguos
Hi, I apologize for being naive and new. I am trying to read the same cell in multiple excel files. I have figured out how to rename each file ending with a counter from *0001 to *5000. If I want to read cell A1 in each file, and copy and paste that to an existing spreadsheet into A1 to A5000, how would I accomplish this? I was able to name each spreadsheet with the counter but I do not know how to efficiently read and write. Activex seems the best way?
Thank you in advance, RO
Respuesta aceptada
Más respuestas (1)
I'd hope all the files to be read are in the same location and have at least some naming convention in common. If so, the simplest thing is
d=dir('Appropriatewildcardexpression*.xls'); % return the directory list of desired files
outfile='Yourdesiredoutputfilename.xls')
L=length(d); % how many found
v=zeros(L,1); % array to hold values
for i=1:length(d)
v(i)=xlsread(d(i).name,'A1'); % read the values in array
end
xlswrite(outfile,'A:') % write in column A
ADDENDUM
Actually, if you can use something other than Excel when creating these (like a regular text file) or even better stream the output to a single file you could eliminate both of the problems with Excel -- slow the easy-to-code way, pita to code the other.
Categorías
Más información sobre ActiveX en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!