ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Clear all Data on sheet after a given row (https://www.excelbanter.com/excel-programming/331090-how-clear-all-data-sheet-after-given-row.html)

Chirs

How to Clear all Data on sheet after a given row
 
I am looking for a way to Clear all cells on a speadsheet after a given row
.. For instance: clear all data below row 1000. In particular, I am lookinfg
for a way to do it with out programatically determinig the LAST row that has
data and having to cycle thru each row and delete it. Is there a line of
code that would basically say: Range. Rows( 1001) to Rows("End of spread
sheet data" ).Clear. I dont want to force it to create the sheets row limit
(row 16000+) either, I just want it to know where the last row data is in.
Any assistance would be helpful. Thanks to All

STEVE BELL

How to Clear all Data on sheet after a given row
 
The easiest way is:

Dim lrw As Long

lrw = Cells.SpecialCells(xlLastCell).Row

If lrw 1000 then
Range(Rows(1000), Rows(lrw)).EntireRow.Delete
End If

Or:

If Cells.SpecialCells(xlLastCell).Row 1000
Range(Rows(1000),
Rows(Cells.SpecialCells(xlLastCell).Row)).EntireRo w.Delete
End If

--
steveB

Remove "AYN" from email to respond
"Chirs" wrote in message
...
I am looking for a way to Clear all cells on a speadsheet after a given
row
. For instance: clear all data below row 1000. In particular, I am
lookinfg
for a way to do it with out programatically determinig the LAST row that
has
data and having to cycle thru each row and delete it. Is there a line of
code that would basically say: Range. Rows( 1001) to Rows("End of spread
sheet data" ).Clear. I dont want to force it to create the sheets row
limit
(row 16000+) either, I just want it to know where the last row data is
in.
Any assistance would be helpful. Thanks to All




Dave Peterson[_5_]

How to Clear all Data on sheet after a given row
 
dim myRow as long
myrow = 1000
range(myrow + 1 & ":65536").clear '.clearcontents


I think I'd use this:

Dim myRow As Long
myRow = 1000
With ActiveSheet
Range(myRow + 1 & ":" & .Rows.Count).Clear '.clearcontents
End With

Then I don't have to worry about when that number of rows gets bigger than 65k!
<vbg.


Chirs wrote:

I am looking for a way to Clear all cells on a speadsheet after a given row
. For instance: clear all data below row 1000. In particular, I am lookinfg
for a way to do it with out programatically determinig the LAST row that has
data and having to cycle thru each row and delete it. Is there a line of
code that would basically say: Range. Rows( 1001) to Rows("End of spread
sheet data" ).Clear. I dont want to force it to create the sheets row limit
(row 16000+) either, I just want it to know where the last row data is in.
Any assistance would be helpful. Thanks to All


--

Dave Peterson


All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com