I nead help, xlsread(file,-1).
14 views (last 30 days)
Show older comments
from doc:
[num,txt,raw] = xlsread(filename,-1) opens an Excel window to interactively select data. Select the worksheet, drag and drop the mouse over the desired range, and click OK.
How can I save this selected area (ex ‘A3:AB187’ or other) to use as a variable.I wont read in the same area (ex ‘A3:AB187’ or other) with multiple files.
Thanks,
Jola
3 Comments
Accepted Answer
Oleg Komarov
on 1 Aug 2012
I'll rephrase the question to make it clear.
How can I return the address of the data which I selected interactively with:
xlsread(filename,-1)
After a bit of reverse engineering I found a semi-undocumented feature. It is possible to play with the COM object through the 5th input. The syntax I am gonna use is:
[num,txt,raw,custom] = xlsread(filename,sheet,range,'',functionHandle)
Step 1 Create the following function which will query the Address property
function [DataRange, range] = customOut(DataRange)
range = DataRange.Address;
end
Step 2 Now simply import the data with:
[num,txt,raw,address] = xlsread('test.xlsx',-1,[],[],@customOut)
address =
$B$7:$D$12
More 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!