ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Delete all but first line (https://www.excelbanter.com/excel-discussion-misc-queries/162676-delete-all-but-first-line.html)

Danu

Delete all but first line
 
Is there a way to easily delete all the records in a spreadsheet except for
the first line?

I have a spreadsheet with many records which must be updated each day with
new info. I can delete all the records but end up rewriting the column
titles.

Thank you.

JE McGimpsey

Delete all but first line
 
One way:

Use this macro, attached to a button or keyboard shortcut:

Public Sub ClearSheet
With ActiveSheet
.Rows("2:"&.Rows.Count).Clear
End With
End Sub

In article ,
Danu wrote:

Is there a way to easily delete all the records in a spreadsheet except for
the first line?

I have a spreadsheet with many records which must be updated each day with
new info. I can delete all the records but end up rewriting the column
titles.

Thank you.


Kevin B

Delete all but first line
 
This macro is a possibility. Change the starting cell of A1 accordingly:

************************************************** **********
Sub ClearTheWay()

Dim r As Range

Set r = Range("A1").CurrentRegion

r.Range(Cells(2, 1), Cells(r.Rows.Count, _
r.Columns.Count)).Clear

Set r = Nothing

End Sub
************************************************** **********

Press Alt + F11, click INSERT on the menu and select MODULE. You can copy
and paste the macro code verbatim, excluding the lines of asterisks.
--
Kevin Backmann


"Danu" wrote:

Is there a way to easily delete all the records in a spreadsheet except for
the first line?

I have a spreadsheet with many records which must be updated each day with
new info. I can delete all the records but end up rewriting the column
titles.

Thank you.


Rick Rothstein \(MVP - VB\)

Delete all but first line
 
Manually, you could click the "2" in the row header to select the entire row
2 and then follow that up by keying in

Ctrl+Shift+{END}+{DOWN ARROW}

and follow that by pressing {DELETE}.

Rick


"Danu" wrote in message
...
Is there a way to easily delete all the records in a spreadsheet except
for
the first line?

I have a spreadsheet with many records which must be updated each day with
new info. I can delete all the records but end up rewriting the column
titles.

Thank you.




All times are GMT +1. The time now is 07:42 AM.

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