![]() |
delete row
Is there a way to automatically locate the last row with
data and delete it? |
delete row
Hi DF
This will delete the last row on the activesheet Copy the macro and the function in a normal module Sub test() Dim Lr As Long Lr = LastRow(ActiveSheet) ActiveSheet.Rows(Lr).EntireRow.Delete End Sub Function LastRow(sh As Worksheet) On Error Resume Next LastRow = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row On Error GoTo 0 End Function -- Regards Ron de Bruin http://www.rondebruin.nl "DF" wrote in message ... Is there a way to automatically locate the last row with data and delete it? |
delete row
The following code will delete the last row that has data in
column A. Change the column reference to suit your needs. Cells(Rows.Count, "A").End(xlUp).EntireRow.Delete -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "DF" wrote in message ... Is there a way to automatically locate the last row with data and delete it? |
delete row
Dim rng as Range, lastrow as Range
set rng = Activesheet.UsedRange lastrow = rng.rows(rng.rows.count).row Cells(lastRow,1).EntireRow.Delete would be a possibility. or Dim rng as Range set rng = Activesheet.usedRange rng.rows(rng.rows.count).EntireRow.Delete -- Regards, Tom Ogilvy "DF" wrote in message ... Is there a way to automatically locate the last row with data and delete it? |
All times are GMT +1. The time now is 08:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com