Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

obtaining a data range from Excel using ActiveX?

63 views
Skip to first unread message

Bert Jagers

unread,
Dec 19, 2000, 4:19:29 PM12/19/00
to
I know that it's possible to select a range in Excel from within Matlab
by doing something like (sht is a ActiveX Excel sheet object):

cl1=get(sht.Cells,'item',RANGE(2),RANGE(1));
cl2=get(sht.Cells,'item',RANGE(4),RANGE(3));
rng=get(sht,'range',cl1,cl2);
B=get(rng,'value')

However, if I have interactively selected a range in Excel. How can I
retrieve the bounds of that range and/or load the data into Matlab?

Bert


Sent via Deja.com
http://www.deja.com/

Jordan Rosenthal

unread,
Dec 19, 2000, 6:00:24 PM12/19/00
to
Bert,

Referencing the Selection property of the Excel Application object will
return the currently active range:

CurrentRange = ExcelApplication.Selection


(Actually, the Selection property returns whatever is selected in the Excel
application. Usually, though, you would call this after selecting some
cells, in which case it returns the Range object associated with the cells.)

Jordan

"Bert Jagers" <hraj...@my-deja.com> wrote in message
news:91o1q6$1h9$1...@nnrp1.deja.com...

Bert Jagers

unread,
Dec 20, 2000, 7:10:39 AM12/20/00
to

> Jordan Rosenthal wrote:

> CurrentRange = ExcelApplication.Selection

Thank you, Jordan. I had already expected that you would be the one
answering.

> Actually, the Selection property returns whatever is selected in
> the Excel application.

Hm, hadn't thought of that yet. Seems that I will have to do a bit more
to verify what has been selected.

Thanks again,

Sander Aerts

unread,
Oct 27, 2009, 7:37:03 AM10/27/09
to
Hello,

I have a somewhat related question to this topic. I am trying to use a COM server to interact with Excel, as such I need to actively select cells myself.

rngs is a cell object containing the cellstrings to be selected, with a semi colon (;) at the end. When making the string of cells to be selected as follows:

cells = [rngs{:}];
cells = cells(1:end-1);

I retreive a string like:
cells = 'A1;A2;A3;....;C3'
basically containing all the cells i need...

When i enter this into the Excel com object like:

Excel.ActiveSheet.Range(cells).Select (or whatever other thing i need to do with these cells)
I get an error. Need to say that the list of cells to be selected is very long and this procedure works when only a few cells need to be selected.

Does anybody know the limitations on the number of cells to be selected at once?

Thanks

0 new messages