Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Delete Last 10 Rows in Worksheet

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delete Last 10 Rows in Worksheet

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Delete Last 10 Rows in Worksheet

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Delete Last 10 Rows in Worksheet

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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Delete Last 10 Rows in Worksheet

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.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delete Last 10 Rows in Worksheet

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.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Delete Last 10 Rows in Worksheet

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.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Delete Last 10 Rows in Worksheet

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.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Delete Last 10 Rows in Worksheet

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Rows in a protected worksheet Kathy Connelly Excel Discussion (Misc queries) 2 June 10th 08 07:39 PM
how do I delete even or odd rows in a worksheet thanks Excel Discussion (Misc queries) 1 April 26th 07 11:21 PM
Delete ANY blank rows on worksheet Anita Excel Discussion (Misc queries) 7 August 31st 06 05:41 PM
How to delete empty rows in a worksheet Bob Reynolds[_3_] Excel Programming 0 June 24th 04 11:04 PM
Delete empty rows in a worksheet Scott Excel Programming 3 January 8th 04 10:09 PM


All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"