Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Clear Sheet in Excel

Hi,

I have two sheets in an Excel file, Sheet1 and Sheet2. In Sheet1, I
have data columns from A to H with an unkown number of rows. In Sheet2,
I have data columns from A to Q with an unkown number of rows.

Now I want to clear everything from row 2 in Sheet1. And I also want to
clear everything from row 2 in Sheet2 with the exception that the value
in cell "E2" should remain.

I have created a macro as follows:

' Clear Sheet1 and Sheet2 (but keep the the first three rows)
Sheet1.Range("A2", "H65000").Clear()

' The cell of E2 should NOT be cleared!
Sheet2.Range("A2", "D2").Clear()
Sheet2.Range("F2", "Q2").Clear()
Sheet2.Range("A3", "Q65000").Clear()

Two issues he

1) These statements are syntactically incorrect. Could anyone correct
the syntax for me?

2) I didn't intend to use "65000" as the upper bound. But how to get
the maximu row number with non-empty cells?

Thanks!
-Emily

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Clear Sheet in Excel

Emily, see other thread

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Emily" wrote in message oups.com...
Hi,

I have two sheets in an Excel file, Sheet1 and Sheet2. In Sheet1, I
have data columns from A to H with an unkown number of rows. In Sheet2,
I have data columns from A to Q with an unkown number of rows.

Now I want to clear everything from row 2 in Sheet1. And I also want to
clear everything from row 2 in Sheet2 with the exception that the value
in cell "E2" should remain.

I have created a macro as follows:

' Clear Sheet1 and Sheet2 (but keep the the first three rows)
Sheet1.Range("A2", "H65000").Clear()

' The cell of E2 should NOT be cleared!
Sheet2.Range("A2", "D2").Clear()
Sheet2.Range("F2", "Q2").Clear()
Sheet2.Range("A3", "Q65000").Clear()

Two issues he

1) These statements are syntactically incorrect. Could anyone correct
the syntax for me?

2) I didn't intend to use "65000" as the upper bound. But how to get
the maximu row number with non-empty cells?

Thanks!
-Emily



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Clear Sheet in Excel

Sheet1.Range("A2:H65000").Clear

' The cell of E2 should NOT be cleared!
Sheet2.Range("A2:D2").Clear
Sheet2.Range("F2:Q2").Clear
Sheet2.Range("A3:Q65000").Clear

--
Regards,
Tom Ogilvy

"Emily" wrote:

Hi,

I have two sheets in an Excel file, Sheet1 and Sheet2. In Sheet1, I
have data columns from A to H with an unkown number of rows. In Sheet2,
I have data columns from A to Q with an unkown number of rows.

Now I want to clear everything from row 2 in Sheet1. And I also want to
clear everything from row 2 in Sheet2 with the exception that the value
in cell "E2" should remain.

I have created a macro as follows:

' Clear Sheet1 and Sheet2 (but keep the the first three rows)
Sheet1.Range("A2", "H65000").Clear()

' The cell of E2 should NOT be cleared!
Sheet2.Range("A2", "D2").Clear()
Sheet2.Range("F2", "Q2").Clear()
Sheet2.Range("A3", "Q65000").Clear()

Two issues he

1) These statements are syntactically incorrect. Could anyone correct
the syntax for me?

2) I didn't intend to use "65000" as the upper bound. But how to get
the maximu row number with non-empty cells?

Thanks!
-Emily


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
Copy Sheet to new Sheet and clear cells on original sheets Boiler-Todd Excel Discussion (Misc queries) 7 September 23rd 09 10:02 PM
Copy sheet and clear cells on new sheet at sametime. Brad Withrow Excel Programming 2 April 10th 06 12:49 AM
Clear Sheet parteegolfer Excel Programming 1 April 2nd 06 07:01 AM
Clear a sheet [email protected] Excel Programming 2 March 2nd 06 10:44 PM
msg box to clear a sheet Curt D. Excel Programming 2 January 14th 06 08:00 AM


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

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"