VBA: Handling Selections


Posted by jsp on October 30, 2000 9:28 AM


Is it possible to locate the first cell in a collection
using VBA?

Using "Selection.Address" you can get the whole range,
However I would like to do different things with
different columns and rows from a "Selection", and
that's why I would like to locate individual cells...


Thanks in advance!

Posted by Christopher Mains on October 30, 2000 9:53 AM

I think I have an idea, but I will need a little help trying to understand your exact needs can you possibly clarify? I will help you to the best of my abilities.
Christopher

Posted by jsp on October 30, 2000 2:12 PM

I think I have an idea, but I will need a little help trying to understand your exact needs can you possibly clarify? I will help you to the best of my abilities.


Christopher:

Thanks for your reply,

There are numerous applications that made me ask
this question. Right now, I'm trying to create a
format for a table using VBA.

The idea is that I (or any user) selects an area,
presses a button and then you end up with the
format for the table (different color for headers,
additions formulas at the end of columns, etc.)

If I place some code like:

Selection.address

I end up with the address for the whole area, but
is there a way that I can have the address for
the first cell in the selection, or last cell?

Thanks for your time,

Regards!

Posted by Celia on October 30, 2000 3:14 PM


jsp
Any of the following should locate the first cell in the selected range :-

Selection.Cells(1,1)
Selection.Item(1,1)
Selection (1,1)
Selection (1)

There is useful explanation at :-
http://www.cpearson.com/excel/cells.htm

Celia

Posted by jsp on October 30, 2000 4:33 PM

Celia:

Thanks for your reply,

It's amazing how many things you can do with
Excel.

What you mention here is going to be very useful; now I can
make references within a range! Is it possible, though,
to find out what are the row and column for last cell in
a range;

I mean, I think you could write something like:

Rows =Range(Selection, Selection.End(xldown)).count

To know the last row, but is there a more direct way?

Sorry to bother again!


Thanks!





Posted by Celia on October 30, 2000 4:56 PM

Celia: Thanks for your reply, It's amazing how many things you can do with


Rws = Selection.Rows.Count

Celia