+ Reply to Thread
Results 1 to 10 of 10

Finding the End of a Range

  1. #1
    BigH
    Guest

    Finding the End of a Range

    Hi there,

    Is it possible using code to find the bottom of a range in say column A

    tia BigH



  2. #2
    Bob Phillips
    Guest

    Re: Finding the End of a Range



    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "BigH" <[email protected]> wrote in message
    news:[email protected]...
    > Hi there,
    >
    > Is it possible using code to find the bottom of a range in say column A
    >
    > tia BigH
    >
    >




  3. #3
    Bob Phillips
    Guest

    Re: Finding the End of a Range

    Sure

    LastCell = Range("A1").End(xlDown)

    assuminmg there are no embedded blank cells

    LastCell = Range("A" & Rows.Count).End(xlUp)

    if there might be

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "BigH" <[email protected]> wrote in message
    news:[email protected]...
    > Hi there,
    >
    > Is it possible using code to find the bottom of a range in say column A
    >
    > tia BigH
    >
    >






  4. #4
    Dave Peterson
    Guest

    Re: Finding the End of a Range

    I bet Bob meant:

    Dim LastCell as Range
    set LastCell = Range("A1").End(xlDown)
    'assuminmg there are no embedded blank cells
    set LastCell = Range("A" & Rows.Count).End(xlUp)

    Bob Phillips wrote:
    >
    > Sure
    >
    > LastCell = Range("A1").End(xlDown)
    >
    > assuminmg there are no embedded blank cells
    >
    > LastCell = Range("A" & Rows.Count).End(xlUp)
    >
    > if there might be
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from the email address if mailing direct)
    >
    > "BigH" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi there,
    > >
    > > Is it possible using code to find the bottom of a range in say column A
    > >
    > > tia BigH
    > >
    > >


    --

    Dave Peterson

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Bob's example will find the end of range provided, as he pointed out, there are are no blank lines with in the range. This is a good approach if you know where your range starts.

    Dave's example is commonly used to find the last cell within in a column. This is not the same as Bob's example as you can have multiple ranges within a column with each separated by one or more blank lines.

    Sincerely,
    Leith Ross

  6. #6
    Patrick Molloy
    Guest

    RE: Finding the End of a Range

    here is another alternative
    Sub check()
    Dim here As Range
    Dim lastcell As Range
    Set here = Selection.CurrentRegion
    Set lastcell = Cells(here.Row + here.Rows.Count - 1, here.Column +
    here.Columns.Count - 1)

    lastcell.Select

    End Sub

    "BigH" wrote:

    > Hi there,
    >
    > Is it possible using code to find the bottom of a range in say column A
    >
    > tia BigH
    >
    >
    >


  7. #7
    Dave Peterson
    Guest

    Re: Finding the End of a Range

    Actually, the only difference between Bob's original code and my changes is that
    I added the Dim statement. And I added Set to each of the assignment lines.

    Bob included both options--he just had a typo and forgot to use Set.

    Leith Ross wrote:
    >
    > Bob's example will find the end of range provided, as he pointed out,
    > there are are no blank lines with in the range. This is a good approach
    > if you know where your range starts.
    >
    > Dave's example is commonly used to find the last cell within in a
    > column. This is not the same as Bob's example as you can have multiple
    > ranges within a column with each separated by one or more blank lines.
    >
    > Sincerely,
    > Leith Ross
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=514205


    --

    Dave Peterson

  8. #8
    Bob Phillips
    Guest

    Re: Finding the End of a Range

    This is weird, I cannot see my post in here, nor Leith's. I can see Dave's
    and Patrick's, and the OP, but no more. See it all fin in Google. Odd!

    Bob

    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > Actually, the only difference between Bob's original code and my changes

    is that
    > I added the Dim statement. And I added Set to each of the assignment

    lines.
    >
    > Bob included both options--he just had a typo and forgot to use Set.
    >
    > Leith Ross wrote:
    > >
    > > Bob's example will find the end of range provided, as he pointed out,
    > > there are are no blank lines with in the range. This is a good approach
    > > if you know where your range starts.
    > >
    > > Dave's example is commonly used to find the last cell within in a
    > > column. This is not the same as Bob's example as you can have multiple
    > > ranges within a column with each separated by one or more blank lines.
    > >
    > > Sincerely,
    > > Leith Ross
    > >
    > > --
    > > Leith Ross
    > > ------------------------------------------------------------------------
    > > Leith Ross's Profile:

    http://www.excelforum.com/member.php...o&userid=18465
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=514205
    >
    > --
    >
    > Dave Peterson




  9. #9
    Dave Peterson
    Guest

    Re: Finding the End of a Range

    Netscape 4.78. Still a fine newsreader <vbg>.

    Bob Phillips wrote:
    >
    > This is weird, I cannot see my post in here, nor Leith's. I can see Dave's
    > and Patrick's, and the OP, but no more. See it all fin in Google. Odd!
    >
    > Bob
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    > > Actually, the only difference between Bob's original code and my changes

    > is that
    > > I added the Dim statement. And I added Set to each of the assignment

    > lines.
    > >
    > > Bob included both options--he just had a typo and forgot to use Set.
    > >
    > > Leith Ross wrote:
    > > >
    > > > Bob's example will find the end of range provided, as he pointed out,
    > > > there are are no blank lines with in the range. This is a good approach
    > > > if you know where your range starts.
    > > >
    > > > Dave's example is commonly used to find the last cell within in a
    > > > column. This is not the same as Bob's example as you can have multiple
    > > > ranges within a column with each separated by one or more blank lines.
    > > >
    > > > Sincerely,
    > > > Leith Ross
    > > >
    > > > --
    > > > Leith Ross
    > > > ------------------------------------------------------------------------
    > > > Leith Ross's Profile:

    > http://www.excelforum.com/member.php...o&userid=18465
    > > > View this thread:

    > http://www.excelforum.com/showthread...hreadid=514205
    > >
    > > --
    > >
    > > Dave Peterson


    --

    Dave Peterson

  10. #10
    Bob Phillips
    Guest

    Re: Finding the End of a Range

    I've got IE, and Firefox, I don't need a third. I suppose I could try
    Thunderbird, but I couldn't work out how to flag threads on that.

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > Netscape 4.78. Still a fine newsreader <vbg>.
    >
    > Bob Phillips wrote:
    > >
    > > This is weird, I cannot see my post in here, nor Leith's. I can see

    Dave's
    > > and Patrick's, and the OP, but no more. See it all fin in Google. Odd!
    > >
    > > Bob
    > >
    > > "Dave Peterson" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Actually, the only difference between Bob's original code and my

    changes
    > > is that
    > > > I added the Dim statement. And I added Set to each of the assignment

    > > lines.
    > > >
    > > > Bob included both options--he just had a typo and forgot to use Set.
    > > >
    > > > Leith Ross wrote:
    > > > >
    > > > > Bob's example will find the end of range provided, as he pointed

    out,
    > > > > there are are no blank lines with in the range. This is a good

    approach
    > > > > if you know where your range starts.
    > > > >
    > > > > Dave's example is commonly used to find the last cell within in a
    > > > > column. This is not the same as Bob's example as you can have

    multiple
    > > > > ranges within a column with each separated by one or more blank

    lines.
    > > > >
    > > > > Sincerely,
    > > > > Leith Ross
    > > > >
    > > > > --
    > > > > Leith Ross
    > > >

    > ------------------------------------------------------------------------
    > > > > Leith Ross's Profile:

    > > http://www.excelforum.com/member.php...o&userid=18465
    > > > > View this thread:

    > > http://www.excelforum.com/showthread...hreadid=514205
    > > >
    > > > --
    > > >
    > > > Dave Peterson

    >
    > --
    >
    > Dave Peterson




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 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