+ Reply to Thread
Results 1 to 3 of 3

How to detect last row of Selection?

Hybrid View

Guest How to detect last row of... 04-09-2006, 06:50 PM
Guest Re: How to detect last row of... 04-09-2006, 07:10 PM
Guest Re: How to detect last row of... 04-10-2006, 01:00 AM
  1. #1
    joeu2004@hotmail.com
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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)

    "joeu2004@hotmail.com" <joeu2004hotmailcom@discussions.microsoft.com> wrote
    in message news:C392A8ED-8A6F-48A1-ACE3-507234AF5DC8@microsoft.com...
    > 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. #3
    joeu2004@hotmail.com
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1