Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
TOM TOM is offline
external usenet poster
 
Posts: 47
Default Clear contents of worksheet before populating

Hi everyone, I need a piece of code that will allow me to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Clear contents of worksheet before populating

Tom,

Try

ActiveSheet.Cells.Clear
' or
ActiveSheet.Cells.Clear

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in message
...
Hi everyone, I need a piece of code that will allow me to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Clear contents of worksheet before populating

Of course, the first line should be

ActiveSheet.Cells.ClearContents


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chip Pearson" wrote in message
...
Tom,

Try

ActiveSheet.Cells.Clear
' or
ActiveSheet.Cells.Clear

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in message
...
Hi everyone, I need a piece of code that will allow me to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks





  #4   Report Post  
Posted to microsoft.public.excel.programming
TOM TOM is offline
external usenet poster
 
Posts: 47
Default Clear contents of worksheet before populating

Hi Chip, In the VB application I'm accessing four separate
worksheets at different times and writing to two others at
different times. I want to clear one certain worksheet at
the beginning of the code. Is there a way to statically
tell the VB code which worksheet to clear?

Thanks
-----Original Message-----
Tom,

Try

ActiveSheet.Cells.Clear
' or
ActiveSheet.Cells.Clear

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in

message
...
Hi everyone, I need a piece of code that will allow me

to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Clear contents of worksheet before populating

Tom,

Sure you can. Instead of ActiveSheet, just specify the
appropriate sheet. For example,

Worksheets("Sheet2").Cells.ClearContents


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Tom" wrote in message
...
Hi Chip, In the VB application I'm accessing four separate
worksheets at different times and writing to two others at
different times. I want to clear one certain worksheet at
the beginning of the code. Is there a way to statically
tell the VB code which worksheet to clear?

Thanks
-----Original Message-----
Tom,

Try

ActiveSheet.Cells.Clear
' or
ActiveSheet.Cells.Clear

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in

message
...
Hi everyone, I need a piece of code that will allow me

to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
TOM TOM is offline
external usenet poster
 
Posts: 47
Default Clear contents of worksheet before populating

Thanks Chip, as usual your suggestions work.

You should be getting paid for doing this.

-----Original Message-----
Tom,

Sure you can. Instead of ActiveSheet, just specify the
appropriate sheet. For example,

Worksheets("Sheet2").Cells.ClearContents


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Tom" wrote in

message
...
Hi Chip, In the VB application I'm accessing four

separate
worksheets at different times and writing to two others

at
different times. I want to clear one certain worksheet

at
the beginning of the code. Is there a way to statically
tell the VB code which worksheet to clear?

Thanks
-----Original Message-----
Tom,

Try

ActiveSheet.Cells.Clear
' or
ActiveSheet.Cells.Clear

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in

message
...
Hi everyone, I need a piece of code that will allow

me
to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks


.



.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Clear contents of worksheet before populating

Sheets("Sheet3").Cells.ClearContents

Instead of Activesheet use a sheet name.
The sheet don't have to be active Tom

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Tom" wrote in message ...
Hi Chip, In the VB application I'm accessing four separate
worksheets at different times and writing to two others at
different times. I want to clear one certain worksheet at
the beginning of the code. Is there a way to statically
tell the VB code which worksheet to clear?

Thanks
-----Original Message-----
Tom,

Try

ActiveSheet.Cells.Clear
' or
ActiveSheet.Cells.Clear

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in

message
...
Hi everyone, I need a piece of code that will allow me

to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks



.



  #8   Report Post  
Posted to microsoft.public.excel.programming
TOM TOM is offline
external usenet poster
 
Posts: 47
Default Clear contents of worksheet before populating

This may be a coincidence but a coworker just asked me
almost the same question. Can I clear all cells in a
worksheet EXCEPT for a specific row such as a header row?


-----Original Message-----
Sheets("Sheet3").Cells.ClearContents

Instead of Activesheet use a sheet name.
The sheet don't have to be active Tom

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Tom" wrote in

message ...
Hi Chip, In the VB application I'm accessing four

separate
worksheets at different times and writing to two others

at
different times. I want to clear one certain worksheet

at
the beginning of the code. Is there a way to statically
tell the VB code which worksheet to clear?

Thanks
-----Original Message-----
Tom,

Try

ActiveSheet.Cells.Clear
' or
ActiveSheet.Cells.Clear

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in

message
...
Hi everyone, I need a piece of code that will allow

me
to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks


.



.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Clear contents of worksheet before populating

Tom,

Try something like the following:

With Worksheets("Sheet1")
.Range(.Range("A2"),
..UsedRange.SpecialCells(xlCellTypeLastCell)).Clea rContents
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in message
...
This may be a coincidence but a coworker just asked me
almost the same question. Can I clear all cells in a
worksheet EXCEPT for a specific row such as a header row?


-----Original Message-----
Sheets("Sheet3").Cells.ClearContents

Instead of Activesheet use a sheet name.
The sheet don't have to be active Tom

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Tom" wrote in

message ...
Hi Chip, In the VB application I'm accessing four

separate
worksheets at different times and writing to two others

at
different times. I want to clear one certain worksheet

at
the beginning of the code. Is there a way to statically
tell the VB code which worksheet to clear?

Thanks
-----Original Message-----
Tom,

Try

ActiveSheet.Cells.Clear
' or
ActiveSheet.Cells.Clear

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Tom" wrote in
message
...
Hi everyone, I need a piece of code that will allow

me
to
clear the contents of an entire worksheet so I can
repopulate it with fresh information.

Any suggestions?

Thanks


.



.



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
Clear Contents gibbylinks Setting up and Configuration of Excel 5 October 12th 09 05:04 PM
Clear Contents Secret Squirrel Excel Discussion (Misc queries) 1 February 3rd 09 12:37 AM
How to copy an Excel worksheet with formulas and clear contents. Compeer buddy Excel Discussion (Misc queries) 2 January 29th 08 05:21 PM
weird thing about clear contents of a worksheet.... Jerry Excel Discussion (Misc queries) 2 August 15th 07 08:54 PM
Clear Contents But Not Formula Gancom3 Excel Discussion (Misc queries) 2 February 1st 05 11:30 PM


All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"