Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What cell am I on (Excel 97)

    In a spreadsheet I delete all the rows that contain 0 in one of the records and then move the rest of them up one row. How can I tell which is the last row in a hughe spreadsheet with out have to do End Down?

    Is there a macro that I can make that will display the last row and maybe the last cell on the right by pressing a button?

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What cell am I on (Excel 97)

    The idea is correct. But it has between 20,000 - 30,000 records at different runs. I would just like to see a small window pop up telling me how far down it went.

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: What cell am I on (Excel 97)

    It depends a bit what you want to do when you get there, but:

    SpecialCells(xlLastCell).Select 'is the VBA equivalent of End-Home

    ActiveSheet.UsedRange.Rows.Count 'will give you the last row of all used ranges on the active sheet

    If you want to constrain yourself to a particular column, say B, because it's last row is not as far as the last row for UsedRange:

    Cells(Application.Rows.Count, Columns("B").Column).End(xlUp).Select 'will select last used cell in column B

    If this is part of a larger VBA routine, it's faster to operate on a range or cell without actually using range.Select.

    Does this help?
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What cell am I on (Excel 97)

    Daniel,

    I've just edited my previous post. Does this help?

    John

  5. #5
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What cell am I on (Excel 97)

    Yes, this is what I needed. Just a push and I can work out the rest.

    Thank you

  6. #6
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What cell am I on (Excel 97)

    Daniel,

    Hopefully I understood what you're trying to achieve. You don't need a macro to get to the last row/column.

    Press the "End" Key and then the "Home" key. This should take you to the last row/column of data.

    Or if you really need something in the code (provided it's the last piece of code after your loop to delete the rows):

    Sub WhereAmI()
    WhatRow = ActiveCell.Row
    MsgBox = WhatRow
    End Sub

    John

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: What cell am I on (Excel 97)

    Having read the rest of the thread, something like:

    MsgBox ActiveSheet.UsedRange.SpecialCells(xlLastCell).Add ress

    ... subject to the caveat on UsedRange.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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