Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Delete all rows below my data to the bottom of the sheet

I am dealing with large blocks of data, ranging from 10,000 to 20,000 rows.

Is there a simple way I can use code to delete all rows below my data, down
to the very bottom of the spreadsheet? The # of rows will not be the same
each time.

Any help is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Delete all rows below my data to the bottom of the sheet

Hi Dan,

Following should do the job, starting from your reference column

Sub DeleteRows()
Application.Goto Reference:="R65536C1"
Rows("65536:65536").Select
Range(Selection, Selection.End(xlUp).Offset(1, 0)).Select
Selection.Delete Shift:=xlUp
Range("A1").Select
End Sub

HTH
Cheers
Carim

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Delete all rows below my data to the bottom of the sheet

You cannot delete those rows, if you do so, Excel just fills it up with new
rows. A worksheet has 65536 rows, period. But empty rows do not use space
when the workbook is saved.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan Winterton" <Dan wrote in message
...
I am dealing with large blocks of data, ranging from 10,000 to 20,000

rows.

Is there a simple way I can use code to delete all rows below my data,

down
to the very bottom of the spreadsheet? The # of rows will not be the same
each time.

Any help is greatly appreciated.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Delete all rows below my data to the bottom of the sheet

I know that you can't delete the rows. But the problem is that although
there is no data in those bottom rows, excel thinks that there is. When you
try to add a row later, it tells you that it cannot "shift rows off the
worksheet." -- a common issue with excel.

The solution to this issue is to select all rows below your data, to the
bottom of the worksheet, and delete them, then re-save your document. then,
excel will let you add rows.

All I want to do is use a macro to do the deletion for me. I think all I
need is a line of code that can count how many rows of data I have, then a
statement to select all rows from "last row + 1":65534 (the bottom of the
worksheet), and delete them.

Can anyone help with this? Thanks.

"Bob Phillips" wrote:

You cannot delete those rows, if you do so, Excel just fills it up with new
rows. A worksheet has 65536 rows, period. But empty rows do not use space
when the workbook is saved.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan Winterton" <Dan wrote in message
...
I am dealing with large blocks of data, ranging from 10,000 to 20,000

rows.

Is there a simple way I can use code to delete all rows below my data,

down
to the very bottom of the spreadsheet? The # of rows will not be the same
each time.

Any help is greatly appreciated.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Delete all rows below my data to the bottom of the sheet

LastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
Rows(LastRow+1 & ":" & Rows.Count).Delete

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan Winterton" wrote in message
...
I know that you can't delete the rows. But the problem is that although
there is no data in those bottom rows, excel thinks that there is. When

you
try to add a row later, it tells you that it cannot "shift rows off the
worksheet." -- a common issue with excel.

The solution to this issue is to select all rows below your data, to the
bottom of the worksheet, and delete them, then re-save your document.

then,
excel will let you add rows.

All I want to do is use a macro to do the deletion for me. I think all I
need is a line of code that can count how many rows of data I have, then a
statement to select all rows from "last row + 1":65534 (the bottom of the
worksheet), and delete them.

Can anyone help with this? Thanks.

"Bob Phillips" wrote:

You cannot delete those rows, if you do so, Excel just fills it up with

new
rows. A worksheet has 65536 rows, period. But empty rows do not use

space
when the workbook is saved.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan Winterton" <Dan wrote in

message
...
I am dealing with large blocks of data, ranging from 10,000 to 20,000

rows.

Is there a simple way I can use code to delete all rows below my data,

down
to the very bottom of the spreadsheet? The # of rows will not be the

same
each time.

Any help is greatly appreciated.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Delete all rows below my data to the bottom of the sheet

Works Great. Thanks.

"Bob Phillips" wrote:

LastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
Rows(LastRow+1 & ":" & Rows.Count).Delete

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan Winterton" wrote in message
...
I know that you can't delete the rows. But the problem is that although
there is no data in those bottom rows, excel thinks that there is. When

you
try to add a row later, it tells you that it cannot "shift rows off the
worksheet." -- a common issue with excel.

The solution to this issue is to select all rows below your data, to the
bottom of the worksheet, and delete them, then re-save your document.

then,
excel will let you add rows.

All I want to do is use a macro to do the deletion for me. I think all I
need is a line of code that can count how many rows of data I have, then a
statement to select all rows from "last row + 1":65534 (the bottom of the
worksheet), and delete them.

Can anyone help with this? Thanks.

"Bob Phillips" wrote:

You cannot delete those rows, if you do so, Excel just fills it up with

new
rows. A worksheet has 65536 rows, period. But empty rows do not use

space
when the workbook is saved.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan Winterton" <Dan wrote in

message
...
I am dealing with large blocks of data, ranging from 10,000 to 20,000
rows.

Is there a simple way I can use code to delete all rows below my data,
down
to the very bottom of the spreadsheet? The # of rows will not be the

same
each time.

Any help is greatly appreciated.






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
How to delete extra rows from bottom? Lentenrose Excel Discussion (Misc queries) 1 November 10th 06 05:23 PM
How do I repeat rows on the bottom of each sheet in excel? Asma Excel Worksheet Functions 1 March 15th 05 09:37 PM
How do I delete blank rows at the bottom of a spreadsheet to get . Miklaurie Excel Discussion (Misc queries) 1 January 26th 05 02:30 PM
NEED TO REPEAT ROWS AT THE BOTTOM OF EXCEL SPREAD SHEET AQ Mahomed Excel Programming 5 June 7th 04 02:13 PM
Go to last row of data and delete the rest to bottom of s/sheet Tempy Excel Programming 6 April 9th 04 12:33 PM


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

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"