How to find next empty row in Excel Worksheet?
10 views (last 30 days)
Show older comments
Hi,
I am trying to write a matlab code which allows data to be implemented into an Excel spreadsheet at the next available row.
Currently I have been using the code below which allows me to input data to excel cells that i specify. In the long run i want matlab to automatically find the next available row and implement data into columns of that row. I dont really know how to do this and am fairly new to Matlab so would appreciate any help. (the code below is a very simple version of what I am trying to do)
Fx = 10
Fy = 20
Fz = 30
filename = 'filtereddata.xlsx';
xlswrite(filename,Fx,'Sheet1','A1')
xlswrite(filename,Fy,'Sheet1','B1')
xlswrite(filename,Fz,'Sheet1','C1')
4 Comments
Bob Thompson
on 15 Apr 2019
A simple way of doing this would be to read the data that is in the excel sheet and then simply adjust the write dimensions to be past that. This can be a bit of a memory hog, but if you are only reading and writing once you should be ok.
[~ ~ complete] = xlsread('myspreadsheet.xlsx');
lr = size(complete,1);
range = ['A',num2str(lr+1)];
xlswrite('myspreadsheet.xlsx',mydata,range);
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!