PDA

View Full Version : Solved: Clear worksheet except for Row 1 Macro



JimS
09-07-2009, 03:14 PM
Can the following code be modified to not delete the Header Row (Row 1)?

This code clears the entire worksheet (Timeline Data worksheet) if there is data on it, but if it's blank (except for the Header Row 1) it will delete Row 1. I do not want it to every delete Row 1.

Thanks...

JimS



Sub Macro12()

With ThisWorkbook.Worksheets("Timeline Data")
x = .UsedRange.Rows.Count
.Rows("2:" & x).Delete
End With


End Sub

Bob Phillips
09-07-2009, 04:24 PM
Sub Macro12()

With ThisWorkbook.Worksheets("Timeline Data")
x = .UsedRange.Rows.Count
if x >= 2 Then .Rows("2:" & x).Delete
End With

End Sub

mikerickson
09-07-2009, 04:30 PM
Sub Macro12()

With ThisWorkbook.Worksheets("Timeline Data")
Range(.Range("A2"),.UsedRange.Offset(1,0)).EntireRow.Delete
End With

End Sub

JimS
09-08-2009, 05:28 AM
Excellent, Thank you - both of you...