View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Determining the last row in a spreadsheet

As an example:
Sub Tester9()
lastRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row
Debug.Print lastRow
Rows(lastRow).Offset(-1, 0).Resize(2).EntireRow.Delete
ActiveSheet.UsedRange
lastRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row
Debug.Print lastRow

End Sub


--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
or use
Activesheet.UsedRange

--
Regards,
Tom Ogilvy

"Ron de Bruin" wrote in message
...
Hi Tom

Generally not if you delete entire rows

If I delete entire rows with your example it will not reset the last

cell
Only when I save the file



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Tom Ogilvy" wrote in message

...
Generally not if you delete entire rows. I don't discount the method

you
propose is more robust.

--
Regards,
Tom Ogilvy




"Ron de Bruin" wrote in message
...
Hi Al

Remember this is not always the last row with data
The last cell will be reset when you save the workbook.

Try to delete some data and run the sub again.
You see that it rember the last cell when you open the workbook

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Al Lind" wrote in message
...
Works great! Thanks Tom.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!