Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Use END to select last row using a Macro?

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    How can I write a macro to select the last row with data and then go to the next row? Iíve tried to records a macro where I do that, but it just goes to the last row with data and then says ďRange("A59").SelectĒ, where A59 just so happens to be the next row in that case but it wonít work once Iíve added or deleted a data row.

    THANKS!

  2. #2
    New Member
    Join Date
    Feb 2002
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sub FindLastRow()
    If WorksheetFunction.CountA(Cells) > 0 Then
    'Search for any entry, by searching backwards by Rows.
    lastrow = Cells.Find(What:="*", After:=[A1], _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious).Row
    End If
    EndofList = lastrow
    Range("A1").Select
    ActiveCell.Offset(EndofList, 1).Range("A1").Select

    End Sub

  3. #3
    MrExcel MVP Barrie Davidson's Avatar
    Join Date
    Feb 2002
    Location
    Winnipeg
    Posts
    2,330
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-06 14:05, Cosmos75 wrote:
    How can I write a macro to select the last row with data and then go to the next row? Iíve tried to records a macro where I do that, but it just goes to the last row with data and then says ďRange("A59").SelectĒ, where A59 just so happens to be the next row in that case but it wonít work once Iíve added or deleted a data row.

    THANKS!
    This will do the trick:

    Range("A65536").End(xlUp).Offset(1, 0).Select

    Regards,

    Barrie Davidson

    "You're only given a little spark of madness. You mustn't lose it." - Robin Williams

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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