Clear all rows except first two
Another way -
Sub test2()
Dim row1 As Long, rowsCnt As Long
Dim rng As Range
Set rng = ActiveSheet.UsedRange
row1 = rng.Rows(1).Row
rowsCnt = rng.Rows.Count
If row1 < 3 Then
If rowsCnt row1 + 1 Then
rng.Offset(row1 + 1).Resize(rowsCnt - row1 - 1).Clear
End If
End If
End Sub
Regards,
Peter T
"Paul Kraemer" wrote in message
...
Hi,
I am using Excel 2007. I want to write a VBA Subroutine to delete/clear
all
data on a particular worksheet except for the first two rows.
This worksheet can have any number of rows filled with data. Can anyone
give me a hint on how I can select and clear all rows containing data
except
for the first two rows?
Thanks in advance,
Paul
--
Paul Kraemer
|