+ Reply to Thread
Results 1 to 3 of 3

How do I select the last line

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Atlanta
    MS-Off Ver
    Excel 2007
    Posts
    171

    How do I select the last line

    I am trying to select the last line of a database, columns A thru E. So far, I've figured out that I can select the last cell in the row with:

    Rows.End(xlDown).Select
    but how do I select the entire line of data in the last row?

    Thanks.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: How do I select the last line

    You could use this code:
       Dim lastRow As Long
       lastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
       Rows(lastRow).Select
    Regards,
    Antonio

  3. #3
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Atlanta
    MS-Off Ver
    Excel 2007
    Posts
    171

    Re: How do I select the last line

    antoka05 - Thanks, I only wanted to select the last row in columns A thru E since that's how far out the database goes. Your solution seems to select the last row, but the entire row. However, you did spark an idea and I figured it out. Thanks.

        CourseCount = WorksheetFunction.CountA(Range("$A:$A"))
        Range("A" & CourseCount & ":E" & CourseCount).Select

+ 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