Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I clear all cells from all rows except the first row in Sheet1?

How do I clear all cells from all rows except the first row in Sheet1?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default How do I clear all cells from all rows except the first row in Sheet1?

here's one way, but change the "A" to whatever column has the last row of data

Sub test()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Rows("2:" & lastrow).ClearContents
End Sub

--


Gary


"Michael" wrote in message
oups.com...
How do I clear all cells from all rows except the first row in Sheet1?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How do I clear all cells from all rows except the first row in Sheet1?

Michael,
Here's one way. UsedRange allows for situations if you have blank rows above
the header row. If this is never the case you can delete it.

Private Sub CommandButton1_Click()

With Worksheets("Sheet1").UsedRange
.Range("A2", .Cells(.Rows.Count, .Columns.Count)).ClearContents
End With

End Sub

NickHK

"Michael" wrote in message
oups.com...
How do I clear all cells from all rows except the first row in Sheet1?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default How do I clear all cells from all rows except the first row in Sheet1?

As long as the used range doesn't include the last row of the worksheet:

Worksheets("Sheet1").UsedRange.Offset(1).ClearCont ents

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Michael" wrote in message
oups.com...
How do I clear all cells from all rows except the first row in Sheet1?



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
Checking the Cells in Sheet1 with Cells in Sheet2 and replace Checking the cells in Sheet1 with Sheet2 Excel Worksheet Functions 1 August 19th 06 09:29 AM
Display Rows From Sheet1 In Sheet2 (Import) Mythran Excel Worksheet Functions 1 March 24th 06 07:40 PM
Need to copy rows in Sheet1 to different worksheets minx2001[_3_] Excel Programming 0 October 23rd 04 05:44 PM
Need to copy rows in Sheet1 to different worksheets minx2001[_2_] Excel Programming 1 October 23rd 04 04:00 PM
Need to copy rows in Sheet1 to different worksheets minx2001 Excel Programming 1 October 23rd 04 10:13 AM


All times are GMT +1. The time now is 02:45 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"