Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default determine whether the activecell is on the top or bottom

In a user selected single column selection, how do I determine
whether the activecell is on the top or bottom of the selection?
Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default determine whether the activecell is on the top or bottom

Just to you know, the ActiveCell can be located interior to the Selection
(make a Selection and then press the Tab key a few times). Given that, here
is some code you can use...

Location = InStr(Selection.Address, ActiveCell.Address)
If Location = 0 Then
MsgBox "ActiveCell is not at either end of the Selection"
ElseIf Location = 1 Then
MsgBox "ActiveCell is at the beginning of the Selection"
Else
MsgBox "ActiveCell is at the end of the Selection"
End If

--
Rick (MVP - Excel)


"John Smith" wrote in message
...
In a user selected single column selection, how do I determine
whether the activecell is on the top or bottom of the selection?
Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default determine whether the activecell is on the top or bottom

I guess I should mention that my code assumes the selection is contiguous.
If it is not contiguous, then you will have to tell us what the beginning
and end of the selection means as the selection is constructed in the order
the cell or cells are added to it... that means the first and/or last
selected area could be between what looks like outer areas. For example,
select these areas in the order shown (hold down the Control key while
selecting them)... B2:C5, then A7:C9, then E1:G4 and then E6:F8. Now execute
this line in the Immediate Window...

? Selection.Address

and note the order the addresses are printed in... it's the same order you
selected them in. So, which to you consider the first area and which is the
last? Before you answer too quickly, note the top left area is does not have
the leftmost nor topmost cell in it; nor does the bottom right one contain
the rightmost or bottommost cell

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Just to you know, the ActiveCell can be located interior to the Selection
(make a Selection and then press the Tab key a few times). Given that,
here is some code you can use...

Location = InStr(Selection.Address, ActiveCell.Address)
If Location = 0 Then
MsgBox "ActiveCell is not at either end of the Selection"
ElseIf Location = 1 Then
MsgBox "ActiveCell is at the beginning of the Selection"
Else
MsgBox "ActiveCell is at the end of the Selection"
End If

--
Rick (MVP - Excel)


"John Smith" wrote in message
...
In a user selected single column selection, how do I determine
whether the activecell is on the top or bottom of the selection?
Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default determine whether the activecell is on the top or bottom

You could compare rows:

Dim myRng as range
dim myCell as range

set myrng = selection.areas(1) 'or something specific???
set mycell = activecell 'or anything you want.

msgbox myrng.row & vblf & myrng.rows(myrng.rows.count).row & vblf & mycell.row

John Smith wrote:

In a user selected single column selection, how do I determine
whether the activecell is on the top or bottom of the selection?
Thanks.


--

Dave Peterson
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
determine if activecell in specific worksheet and column Scotty9349 Excel Programming 6 July 1st 09 09:09 PM
determine activecell and move to it after running ohter sub... SpeeD Excel Programming 3 February 25th 09 02:18 PM
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
Determine top row and bottom row Andrew Excel Programming 2 May 9th 07 02:28 AM
dislike jump bottom of column by double-clicking the bottom of cel Joe Excel Discussion (Misc queries) 1 April 9th 06 09:27 PM


All times are GMT +1. The time now is 12:06 AM.

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

About Us

"It's about Microsoft Excel"