Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear a full Worksheet in Excel

Status
Not open for further replies.

lb1

Technical User
Apr 19, 2002
109
0
0
US
I would like to clear all the cells from a worksheet. Is there a command to do this or do I need to use a range?
Thanks in advance
 
Hello!

Will ActiveSheet.Cells.Clear do it for you?

Ofer
 
It works if I am in the specific sheet, but if I set the sheet as follows:
Set res = Sheets("2")
ActiveSheet.Cells.Clear
it will not work.
Any idea why?
 
Use res.Clear or if you want to retain formatting use res.ClearContents.

Sheets("2") refers to a sheet named 2 (not the second sheets in the sheets collection. If youe working with the second sheet use Sheets(2), or better still use the actual name of the sheet, just in case the sheets get re-ordered.

A.C.
 
lb1,

You can use ANY worksheet Object with the Clear method. Does not need to be the ActiveSheet...
Code:
AnySheetObject.Clear
faq707-4105 How Can I Make My Code Run Faster?

:)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top