MATLAB: How to use xltoRight, xlDown and similar utilities from MATLAB

MATLABxldownxltorightxlup

I would like to use visual basic utilities like: xlDown, xltoright like described under:

Best Answer

The following example uses the Excel functions xltoRight and xlDown to select a contiguous block of data. For more information on how these functions work, consult your Microsoft documentation.
Note that there must be a block of data around the specified cell B9; otherwise, these Excel functions will select the entire worksheet, as detailed in the Microsoft documentation.
e = actxserver ('Excel.Application') % open Activex server
eWorkbooks = e.Workbooks
exlFile = eWorkbooks.Open('C:\MyFile.xls')%open file
exlSheet1 = exlFile.Sheets.Item('Tabelle1')%Choose Sheet
lastCol = exlSheet1.Range('B9').End('xltoRight').Column % find last column
% Convert column number to Excel column code
if (lastCol <= 26)
lastColchar=char(96+lastCol)
else
lastColchar = [char(96+floor((lastCol-1)/26)) char(97+rem(lastCol-1,26))]
end
lastrow = exlSheet1.Range('B9').End('xldown').Row % find last row
myrange=[lastColchar num2str(lastrow)]
data_ran=['b9:' myrange]
data=exlSheet1.Range(data_ran).Value% These are the requested data
Related Question