delete row

R

Ron de Bruin

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
 
C

Chip Pearson

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
 
T

Tom Ogilvy

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
 
Top