PC Review


Reply
Thread Tools Rate Thread

Delete Last 10 Rows in Worksheet

 
 
Sloth
Guest
Posts: n/a
 
      24th Jan 2008
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.
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      24th Jan 2008
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

"Sloth" wrote:

> 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.

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      24th Jan 2008
Sub hfdksjf()
n = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & n - 9 & ":A" & n).EntireRow.Delete
End Sub

--
Gary''s Student - gsnu200766


"Sloth" wrote:

> 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.

 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      24th Jan 2008
You can do it with this line of code...

Sheets("Sheet1").Cells(Rows.Count, _
"A").End(xlUp).Offset(-9).Resize(10).EntireRow.Delete

--
HTH...

Jim Thomlinson


"Sloth" wrote:

> 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.

 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      24th Jan 2008
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.
--
HTH...

Jim Thomlinson


"Mike H" wrote:

> 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
>
> "Sloth" wrote:
>
> > 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.

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      24th Jan 2008
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/comm...c15&sloc=en-us

Mike

"Jim Thomlinson" wrote:

> 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.
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Mike H" wrote:
>
> > 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
> >
> > "Sloth" wrote:
> >
> > > 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.

 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      24th Jan 2008
Until he upgrades...
--
HTH...

Jim Thomlinson


"Mike H" wrote:

> 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/comm...c15&sloc=en-us
>
> Mike
>
> "Jim Thomlinson" wrote:
>
> > 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.
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "Mike H" wrote:
> >
> > > 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
> > >
> > > "Sloth" wrote:
> > >
> > > > 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.

 
Reply With Quote
 
Sloth
Guest
Posts: n/a
 
      24th Jan 2008
Thank You All.

"Jim Thomlinson" wrote:

> You can do it with this line of code...
>
> Sheets("Sheet1").Cells(Rows.Count, _
> "A").End(xlUp).Offset(-9).Resize(10).EntireRow.Delete
>
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Sloth" wrote:
>
> > 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.

 
Reply With Quote
 
Sloth
Guest
Posts: n/a
 
      24th Jan 2008
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.

"Jim Thomlinson" wrote:

> Until he upgrades...
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Mike H" wrote:
>
> > 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/comm...c15&sloc=en-us
> >
> > Mike
> >
> > "Jim Thomlinson" wrote:
> >
> > > 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.
> > > --
> > > HTH...
> > >
> > > Jim Thomlinson
> > >
> > >
> > > "Mike H" wrote:
> > >
> > > > 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
> > > >
> > > > "Sloth" wrote:
> > > >
> > > > > 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent worksheet Rows to Delete. Shazi Microsoft Excel Programming 1 18th Jun 2008 02:36 PM
how do I delete even or odd rows in a worksheet =?Utf-8?B?dGhhbmtz?= Microsoft Excel Misc 1 26th Apr 2007 11:21 PM
How do I delete rows from a protected worksheet? =?Utf-8?B?RGFuIFQ=?= Microsoft Excel Misc 4 8th Jul 2005 08:16 PM
Delete rows in worksheet rita Microsoft Excel Discussion 4 20th Oct 2004 09:33 PM
Delete empty rows in a worksheet Scott Microsoft Excel Programming 3 8th Jan 2004 10:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:42 PM.