Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete row
Is there a way to automatically locate the last row with
data and delete it? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I delete a macro when the Delete button is not active? | Excel Worksheet Functions | |||
How to Delete a Range in Closed Workbook (to Replace Delete Query) | Excel Discussion (Misc queries) | |||
How do i delete a macro in Excel 2003 when delete isn't highlight | Excel Discussion (Misc queries) | |||
How to delete rows when List toolbar's "delete" isnt highlighted? | Excel Worksheet Functions |