Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default accessing last cell in selection on sheet


Well, i'm writing an application in delphi and i use XLSContainer to
access the cells in an xls document.
I need to find a method that would help me to get the
coordinates(column,row) of the last selected cell in the selection.

so far found this methods:
XLSContainer1.Application.ActiveCell.Column
XLSContainer1.Application.ActiveCell.Row
XLSContainer1.Application.ActiveWindow.RangeSelect ion.Columns.Count
XLSContainer1.Application.ActiveWindow.RangeSelect ion.Rows.Count
XLSContainer1.Application.Range[str,str].Activate

With these methods i've managed to access all cells but only when the
selction goes
from left to right and from up to down....If i could get he
coordinates(column,row) of the last selected cell in the selection i
will solve my problem!

Hope that you understand what i wrote:)
koko


--
gnosis
------------------------------------------------------------------------
gnosis's Profile: http://www.excelforum.com/member.php...o&userid=16806
View this thread: http://www.excelforum.com/showthread...hreadid=320055

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default accessing last cell in selection on sheet

If I understand correctly, the last selected cell should
be the active cell in which case u could simply get the
address.

dim a as string
a= activecell.address

-----Original Message-----

Well, i'm writing an application in delphi and i use

XLSContainer to
access the cells in an xls document.
I need to find a method that would help me to get the
coordinates(column,row) of the last selected cell in the

selection.

so far found this methods:
XLSContainer1.Application.ActiveCell.Column
XLSContainer1.Application.ActiveCell.Row
XLSContainer1.Application.ActiveWindow.RangeSelec tion.Colu

mns.Count
XLSContainer1.Application.ActiveWindow.RangeSelec tion.Rows

..Count
XLSContainer1.Application.Range[str,str].Activate

With these methods i've managed to access all cells but

only when the
selction goes
from left to right and from up to down....If i could get

he
coordinates(column,row) of the last selected cell in the

selection i
will solve my problem!

Hope that you understand what i wrote:)
koko


--
gnosis
----------------------------------------------------------

--------------
gnosis's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=16806
View this thread:

http://www.excelforum.com/showthread...hreadid=320055

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default accessing last cell in selection on sheet


Well, by last cell i mean the most distant from the firs
selected(ActiveCell) in the selection..that's the problem!
For the ActiveCell is easy:
diXLSContainer1.Application.ActiveCell.Column;
diXLSContainer1.Application.ActiveCell.Row;

How can i get these values for the most distant cell in the selection
not the ActiveCell

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default accessing last cell in selection on sheet

Not sure, but expect you will have to track and capture
the mousemove events


-----Original Message-----

Well, by last cell i mean the most distant from the first
selected(ActiveCell) in the selection..that's the problem!
For the ActiveCell is easy:
diXLSContainer1.Application.ActiveCell.Column;
diXLSContainer1.Application.ActiveCell.Row;

How can i get these values for the most distant cell in

the selection,
not the ActiveCell?


--
gnosis
----------------------------------------------------------

--------------
gnosis's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=16806
View this thread:

http://www.excelforum.com/showthread...hreadid=320055

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default accessing last cell in selection on sheet


Is there any reason you cannot just select the last cell in th
selection, grab the address, then re-select the original selection?
for example:

RA = Selection.Address ' curren
selection

Selection.End(xlDown).Select 'select last cell
ActiveCell.Offset(-1, 0).Range("A1").Select

topaddressrow1 = ActiveCell.Row 'grab addresses o
last cell
topaddresscolumn1 = ActiveCell.Column

Range(RA).Select 'reselec
original selection

' may be a work around - but hope it helps.
FuzzyDov

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default accessing last cell in selection on sheet


Perhaps I'm way off, but if you really want the row and column values
for the cell the farthest away from the active cell in any selection
(contiguous or not), then try something like this. R and C return the
row and column values in this example. This is not fully tested, but
seems to accomplish what you requested.


Code:
--------------------
Sub Test()
Dim Rng As Range
Dim R As Long
Dim C As Long
Dim RowDif As Long
Dim ColDif As Long
RowDif = 0
ColDif = 0
For Each Rng In Selection
If Abs(ActiveCell.Row - Rng.Row) RowDif Or Abs(ActiveCell.Column - Rng.Column) ColDif Then
RowDif = Abs(ActiveCell.Row - Rng.Row)
ColDif = Abs(ActiveCell.Column - Rng.Column)
R = Rng.Row
C = Rng.Column
End If
Next Rng
Debug.Print R; C
End Sub
--------------------


HTH,
Steve Hieb


--
shieb
------------------------------------------------------------------------
shieb's Profile: http://www.excelforum.com/member.php...o&userid=16404
View this thread: http://www.excelforum.com/showthread...hreadid=320055

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default accessing last cell in selection on sheet

If I have A2 and B1 selected, which is the cell you are looking for?

In otherwords, for a single rectangular selection, the last cell is the
lower right cell, but you say you have no problem getting that - thus you
problem is with a multi area selection and in that case, it is not clear
what constitutes the last cell. What are your rules.


--
Regards,
Tom Ogilvy



"gnosis" wrote in message
...

Well, by last cell i mean the most distant from the first
selected(ActiveCell) in the selection..that's the problem!
For the ActiveCell is easy:
diXLSContainer1.Application.ActiveCell.Column;
diXLSContainer1.Application.ActiveCell.Row;

How can i get these values for the most distant cell in the selection,
not the ActiveCell?


--
gnosis
------------------------------------------------------------------------
gnosis's Profile:

http://www.excelforum.com/member.php...o&userid=16806
View this thread: http://www.excelforum.com/showthread...hreadid=320055



  #8   Report Post  
Posted to microsoft.public.excel.programming
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

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default accessing last cell in selection on sheet

In VBA it would be

Selection.Item(selection.Count)

from the immediate window:

? selection.Address
$C$6:$F$16
? selection.Item(selection.count).Address
$F$16


for a single range/area, the selection or range will always be left to right
and top to bottom, regardless of how the user made the selection.

--
Regards,
Tom Ogilvy


"gnosis" wrote in message
...

Sorry if i was not clear..I'm talking about a single selection, with
only one stroke, one rectangle...
actually i'm woking on delphi application and i use a XLSContainer
component with all objects,methods and properties from
EXCEL-VBA...XLSContainer displays some EXCEL file that is loaded on
FormShow...
.finnaly i need to access all the cells from a single selection made
by a client(by some buttonclick-event or whatever) and put the values
from the cells in a database..
So far i manage to get the number of columns and rows in the selection
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 first
activCell in the selection i will know about the direction of the
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!!!


--
gnosis
------------------------------------------------------------------------
gnosis's Profile:

http://www.excelforum.com/member.php...o&userid=16806
View this thread: http://www.excelforum.com/showthread...hreadid=320055



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel sheet: selection of cell or rows not visible. Hisoul Excel Worksheet Functions 2 May 16th 07 09:06 PM
Problem seeing and accessing top of sheet egii Excel Discussion (Misc queries) 1 January 11th 07 02:52 AM
Cell selection in non-active sheet Otto Moehrbach[_6_] Excel Programming 1 July 16th 04 05:16 PM
Capture listbox selection to a cell in a different sheet Marcie Excel Programming 2 September 19th 03 12:15 PM
Accessing a textbox on a sheet.... Cyril[_2_] Excel Programming 1 August 11th 03 06:37 PM


All times are GMT +1. The time now is 11:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"