Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default select contents of entire worksheet

I'm trying to clear the contents of an entire worksheet
from a macro but I can't find any way of doing this.
I don't want to delete the sheet only clear the contents.

I've gone round in circles with the range(???).clearcontents
style as I can only see that defining the maximum number of
possible cells (ie range("A1:IV65536").clearcontents) will ensure
that the whole sheet is cleared.

Am I just missing something obvious ? or is this the way to do it.

Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default select contents of entire worksheet

Dave you can use a any of the following:
cells.clear
worksheets("Sheet1").cells.clear
Sheet1.cells.clear
Worksheets(1).cells.clear

Jeff

-----Original Message-----
I'm trying to clear the contents of an entire worksheet
from a macro but I can't find any way of doing this.
I don't want to delete the sheet only clear the contents.

I've gone round in circles with the range

(???).clearcontents
style as I can only see that defining the maximum number

of
possible cells (ie range("A1:IV65536").clearcontents)

will ensure
that the whole sheet is cleared.

Am I just missing something obvious ? or is this the way

to do it.

Dave

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default select contents of entire worksheet

Dave,

Its a little sneaky, that's why you missed it... Also you may not be
familiar yet with the Cells object.

Range("$A$1") is the same as Cells(1,1) in code.
Range("$A$1:$E$6") is the same as Range(Cells(1,1),Cells(5,6))

Cells().ClearContents

Cells() usually takes arguments for row and column. Not putting in
arguments specifies all cells.

I like the cells object since it is easier for me to use variables in it
with less confusion and typos.

steve

"Dave" wrote in message
...
I'm trying to clear the contents of an entire worksheet
from a macro but I can't find any way of doing this.
I don't want to delete the sheet only clear the contents.

I've gone round in circles with the range(???).clearcontents
style as I can only see that defining the maximum number of
possible cells (ie range("A1:IV65536").clearcontents) will ensure
that the whole sheet is cleared.

Am I just missing something obvious ? or is this the way to do it.

Dave



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default select contents of entire worksheet

In VBA this seems to work for me


Dim sht As worksheet

Set sht = Worksheets("Balance Sheet")
With sht.Cells
.ClearContents
.ClearOutline
.Clear
End With

"Dave" wrote in message
...
Thanks to everyone, its sorted !!

On Thu, 31 Jul 2003 15:36:54 +0100, Dave <newsgroups@edward-
thompson*nospam*.com wrote:

I'm trying to clear the contents of an entire worksheet
from a macro but I can't find any way of doing this.
I don't want to delete the sheet only clear the contents.

I've gone round in circles with the range(???).clearcontents
style as I can only see that defining the maximum number of
possible cells (ie range("A1:IV65536").clearcontents) will ensure
that the whole sheet is cleared.

Am I just missing something obvious ? or is this the way to do it.

Dave








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default select contents of entire worksheet

Careful out there...

Cells.Clear clears everything, contents, format, etc.
Cells.ClearContents just clears the contents.

steve

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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 entire contents worksheet into new workbook, link but editabl ellyk Excel Discussion (Misc queries) 0 May 12th 10 08:49 PM
Using Cell Contents to Select Worksheet with Same Name as Cell Con Alan Sexter Excel Worksheet Functions 14 June 22nd 09 04:59 AM
why does this macro select the entire worksheet when run? Dave F Excel Discussion (Misc queries) 6 March 1st 07 01:19 PM
Select the entire row shantanu oak Excel Discussion (Misc queries) 5 July 17th 06 11:34 AM
Printing Entire Contents of Cell waterdawg Excel Discussion (Misc queries) 1 August 31st 05 09:03 PM


All times are GMT +1. The time now is 08:15 PM.

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"