View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
gnosis[_3_] gnosis[_3_] is offline
external usenet poster
 
Posts: 1
Default accessing last cell in selection on sheet


Sorry if i was not clear..I'm talking about a single selection, wit
only one stroke, one rectangle...
actually i'm woking on delphi application and i use a XLSContaine
component with all objects,methods and properties fro
EXCEL-VBA...XLSContainer displays some EXCEL file that is loaded o
FormShow...
..finnaly i need to access all the cells from a single selection mad
by a client(by some buttonclick-event or whatever) and put the value
from the cells in a database..
So far i manage to get the number of columns and rows in the selectio
by these methods:
XLSContainer1.Application.ActiveWindow.RangeSelect ion.Columns.Count
XLSContainer1.Application.ActiveWindow.RangeSelect ion.Rows.Count

and coordinates of the first cell in the selection
XLSContainer1.Application.ActiveCell.Column
XLSContainer1.Application.ActiveCell.Row

the problem is that i cannot predict the direction of the selection:
there are four possibilities:
- to select from left to right,up to down
- to select from rigt to left, up to down
- to select from left to right, down to up
- to select from right to left, down to up
if i could get the coordinates of the most distant cell from the firs
activCell in the selection i will know about the direction of th
movement of the client.
I can get these values in VB editor with some
VB macro like
If TypeName(Selection) < "Range" Then Exit Sub
For Each cell In Selection

cell.Activate
...some code
Next cell
but it's usles in delphi
if anybody have an idea i would be greatfull
Thanx so far!!

--
gnosi
-----------------------------------------------------------------------
gnosis's Profile: http://www.excelforum.com/member.php...fo&userid=1680
View this thread: http://www.excelforum.com/showthread.php?threadid=32005