ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro that Deletes All rows except first row (https://www.excelbanter.com/excel-programming/367500-macro-deletes-all-rows-except-first-row.html)

curtney

Macro that Deletes All rows except first row
 

Greetings everyone!

How can I delete all rows in an excel sheet except the first row?

I have an excel sheet where the first row has header information and
the subsequent rows contains data. I would like to run a vba macro that
clears/delete all the data , starting from row 2, in the excel sheet but
retains the header information in row 1.

Curtney Jacobs


--
curtney
------------------------------------------------------------------------
curtney's Profile: http://www.excelforum.com/member.php...o&userid=36469
View this thread: http://www.excelforum.com/showthread...hreadid=562327


Kaak[_84_]

Macro that Deletes All rows except first row
 

Rows(1).Offset(1, 0).Resize(Rows.Count - 1).ClearContent

--
Kaa
-----------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...nfo&userid=751
View this thread: http://www.excelforum.com/showthread.php?threadid=56232


curtney[_2_]

Macro that Deletes All rows except first row
 

Thanks, that did the trick! All the rows get deleted from row 2
onwards!

Is there a way to reset the active cell back to the second row after
deletion? Meaning the active row/cell should be the second row again.

Thanks,

Curtney


--
curtney
------------------------------------------------------------------------
curtney's Profile: http://www.excelforum.com/member.php...o&userid=36469
View this thread: http://www.excelforum.com/showthread...hreadid=562327



All times are GMT +1. The time now is 02:03 AM.

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