I need a macro that can delete the last ten rows in the worksheet. Column A
will always contain information on the last row, but has a lot of gaps in the
rest of the column.
Mike H - 24 Jan 2008 17:34 GMT
Maybe
Sub substance()
lastrow = Range("A65536").End(xlUp).Row
For x = lastrow To (lastrow - 9) Step -1
Rows(x).EntireRow.Delete
Next
End Sub
Mike
> I need a macro that can delete the last ten rows in the worksheet. Column A
> will always contain information on the last row, but has a lot of gaps in the
> rest of the column.
Jim Thomlinson - 24 Jan 2008 17:46 GMT
65536 assumes that Sloth is not on XL2007 which has a lot more rows than
that. You might consider using rows.count to define the end of the sheet.

Signature
HTH...
Jim Thomlinson
> Maybe
>
[quoted text clipped - 10 lines]
> > will always contain information on the last row, but has a lot of gaps in the
> > rest of the column.
Mike H - 24 Jan 2008 18:00 GMT
Jim,
Thanks for the tip, I must get into th habit of doing that with the advent
of 2007 but in this case and from the OP's other thread I knew 65536 was
appropriate
http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public
.excel.misc&mid=d8044b0d-14a6-48d8-99b4-6b4496d0ac15&sloc=en-us
Mike
> 65536 assumes that Sloth is not on XL2007 which has a lot more rows than
> that. You might consider using rows.count to define the end of the sheet.
[quoted text clipped - 13 lines]
> > > will always contain information on the last row, but has a lot of gaps in the
> > > rest of the column.
Jim Thomlinson - 24 Jan 2008 18:09 GMT
Until he upgrades...

Signature
HTH...
Jim Thomlinson
> Jim,
>
[quoted text clipped - 23 lines]
> > > > will always contain information on the last row, but has a lot of gaps in the
> > > > rest of the column.
Sloth - 24 Jan 2008 18:20 GMT
LOL, that'l be the day. I have to fight tooth and nail for every scrap I
get. I've been requesting a hard-drive upgrade for a while with no luck (I
am 70GB full of an 80GB drive).
I went ahead and used rows.count anyways, just in case ;). Thanks again.
> Until he upgrades...
>
[quoted text clipped - 25 lines]
> > > > > will always contain information on the last row, but has a lot of gaps in the
> > > > > rest of the column.
Gary''s Student - 24 Jan 2008 17:39 GMT
Sub hfdksjf()
n = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & n - 9 & ":A" & n).EntireRow.Delete
End Sub

Signature
Gary''s Student - gsnu200766
> I need a macro that can delete the last ten rows in the worksheet. Column A
> will always contain information on the last row, but has a lot of gaps in the
> rest of the column.
Jim Thomlinson - 24 Jan 2008 17:42 GMT
You can do it with this line of code...
Sheets("Sheet1").Cells(Rows.Count, _
"A").End(xlUp).Offset(-9).Resize(10).EntireRow.Delete

Signature
HTH...
Jim Thomlinson
> I need a macro that can delete the last ten rows in the worksheet. Column A
> will always contain information on the last row, but has a lot of gaps in the
> rest of the column.
Sloth - 24 Jan 2008 18:16 GMT
Thank You All.
> You can do it with this line of code...
>
[quoted text clipped - 4 lines]
> > will always contain information on the last row, but has a lot of gaps in the
> > rest of the column.