Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 418
Default How to detect last row of Selection?

I want to have the following loop:

for each cell in Selection
if 'cell in last row in Selection' and 'condition based on cell.value'
then
' process cell in last row
else
' process other cells normally
end if
next

How do I implement the test "cell in last row in Selection"?

Note: Selection is an n-by-m area. So simply testing
"something = last cell of Selection" will not suffice. I need
to recognize any cell in the last row.

Besides, I don't even know how to implement "something =
last cell of Selection". I don't know how to write "something"
(some property of cell?); and I don't know how to write "last
cell of Selection". (Klunk!).

For my edification, I would appreciate it if someone would
tell me how to implement "something = last cell in Selection",
even though that does not address my original problem
above.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to detect last row of Selection?

lr = rows(selection.row+selection.rows.count-1).row
for each cell in Selection
If cell.row = lr then
' process cell in last row
else
' process other cells normally
end if
next


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

" wrote
in message ...
I want to have the following loop:

for each cell in Selection
if 'cell in last row in Selection' and 'condition based on cell.value'
then
' process cell in last row
else
' process other cells normally
end if
next

How do I implement the test "cell in last row in Selection"?

Note: Selection is an n-by-m area. So simply testing
"something = last cell of Selection" will not suffice. I need
to recognize any cell in the last row.

Besides, I don't even know how to implement "something =
last cell of Selection". I don't know how to write "something"
(some property of cell?); and I don't know how to write "last
cell of Selection". (Klunk!).

For my edification, I would appreciate it if someone would
tell me how to implement "something = last cell in Selection",
even though that does not address my original problem
above.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 418
Default How to detect last row of Selection?

Bob Phillips wrote:
lr = rows(selection.row+selection.rows.count-1).row
for each cell in Selection
If cell.row = lr then
' process cell in last row


Perfect! Thanks.

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
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
To detect changes in a worksheet Sinus Log Excel Programming 4 December 8th 05 07:43 AM
Object Type of a selection... counting rows in a selection Acid-Sky[_2_] Excel Programming 3 August 23rd 05 09:53 AM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM


All times are GMT +1. The time now is 03:23 PM.

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"