Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for noticing. Force of habit I guess.
-- Cheers, Ryan "Rick Rothstein" wrote: Rows("3:" & Rows.Count).Delete Shift:=xlUp You can leave of the Shift argument as it won't matter whether Excel chooses to shift up or left... there is no data so it won't matter. So your code line becomes nice and short... Rows("3:" & Rows.Count).Delete -- Rick (MVP - Excel) "Ryan H" wrote in message ... I would do it 1 or 2 ways. If you want to completly delete all rows below Row 2. Use this: Sub DeleteRows() Rows("3:" & Rows.Count).Delete Shift:=xlUp End Sub If you just want to clear the contents of the cell, but still preserve the formatting of the cell. Use this: Sub ClearData() Rows("3:" & Rows.Count).ClearContents End Sub This code will work for any version of Excel. Hope this helps! If so, let me know, click "YES" below. -- Cheers, Ryan "Paul Kraemer" wrote: 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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to clear rows before copying data | Excel Programming | |||
Clear rows with no data? | Excel Programming | |||
How do I clear all cells from all rows except the first row in Sheet1? | Excel Programming | |||
Help to clear data & delete rows | Excel Programming | |||
macro to clear rows | Excel Programming |