Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - need syntax for deleting the last row. 1

Status
Not open for further replies.

srogers

Technical User
Aug 15, 2000
201
0
0
US
I'm successfully finding the last row - at least that's what the MsgBox tells me. The problem is that the first row is being deleted instead of the 31st row (which it is finding).


Sub testDelete()
Dim LastRow As Long

LastRow = ActiveSheet.Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row

MsgBox ("Last Row is: " & LastRow - 1)

Worksheets("A").Cells(LastRow - 1).EntireRow.Delete
End Sub

I also tried .ClearContents
and
Delete Shift:=xlShiftUp

Thank you -
 
Have you tried this ?
Worksheets("A").Cells(LastRow - 1[highlight], 1[/highlight]).EntireRow.Delete

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top