Inserting a data column into an existing Excel file

20 views (last 30 days)
I would like a program that can insert a data column into an existing file. I will now extend this program to insert such a data column automatically into all files within a folder. Finally, I will extend this program again to insert same data column automatically into all files within all folders meaning, the program will access all the folders and files within each folder to insert this data column.
To make it more explicit, let’s say I have a file of 2 columns (10 rows each) and I want to insert a 3rd column that will contain numbers 2 to 20 in steps of 2 i.e. 2,4,6,8,10,12,14,16,18,20.
Please do let me know if you need more clarifications.
Thank you as I await your favourable response
  2 Comments
Image Analyst
Image Analyst on 12 Jul 2014
Edited: Image Analyst on 12 Jul 2014
dpb, put this as an answer. Congratulations on surpassing 2000 points today! By the way, xlswrite will overwrite existing cells - replace them but not erase existing cells not being "covered up" by what you're sending in to xlswrite. But you're right, ActiveX might be the way to go if you really want to do an "insert" rather than reading with xlsread(), inserting column in MATLAB, then just blasting the new array over what's there with xlswrite().
dpb
dpb on 12 Jul 2014
Edited: dpb on 12 Jul 2014
OK, and thanks.
Star Strider sent a note that he couldn't stand the nearness of approach so added a vote to push over the breakpoint this morning... :)
I'd use the privileges a lot more if there were a way to mark obvious spam, duplicates and the like at the top level instead of having to open them and then go thru the process. That extra (unneeded) effort is a killer on my incentive...

Sign in to comment.

Answers (1)

dpb
dpb on 12 Jul 2014
Edited: dpb on 12 Jul 2014
doc xlswrite
altho I'm not positive whether it'll add the other column w/o destroying existing, I think it will...
But, for so many files you probably ought to be using ActiveX calls instead for efficiency. A "read" tutorial by Image Analyst; it'll probably be of benefit for the write side as well...

Community Treasure Hunt

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

Start Hunting!