PDA

View Full Version : [SOLVED] Delete table last row



luizmachado
01-14-2016, 06:15 PM
I'm trying to delete the last row of my table. I recorded a macro to "track the path" and modified as I wanted, but it isn't working and I don't know why. Do you guys know what I can do?

This is the code:

Sub DeleteLastRow() Dim aux As Long
lrTest = Sheets("Monthly Expenses").Range("B" & Rows.Count).End(xlUp).Row
aux = lrTest - 22
Selection.ListObject.ListRows(aux).Delete
End Sub
Sub DeleteLastRow()
Dim aux As Long
lrTest = Sheets("Monthly Expenses").Range("B" & Rows.Count).End(xlUp).Row
aux = lrTest - 22
Selection.ListObject.ListRows(aux).Delete
End Sub

It gives me error "91". I guess it's something with this "ListRows(aux)". I already tested the "lrTest" (last row test) and I gives me the right value.

Ps: I tried to link "ExcelForum"'s and "MrExcel"'s posts, but it won't let me through. There's a post with identical title on both forums.
Ps2: That's whats happening when I post my code between the tags, so in order to be clean to read, I'm posting it below without tags.

luizmachado
01-14-2016, 06:32 PM
It was solved on "ExcelForum"'s post.