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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initialize/Emtpy Workbook

Status
Not open for further replies.

rwei

Programmer
Nov 19, 2004
55
US
I am trying to initialize/empty all the worksheets within a workbook by using VBScript codes.

What's the right way to do this?

Thanks.
 
Hi,
Code:
Dim ws As Worksheet
For Each ws In Worksheets
  ws.Cells.Delete
Next


Skip,
[sub]
[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue][/sub]
 
This seems to delete cell by cell for all the worksheets in a workbook (I have workbook with 10-20 worksheets)? Is this the best way?

I was hoping to initialize/empty workbook in one single lazy code? =), or at least empty worksheet by worksheet thru a loop or something?


 


Where do you see, cell-by-cell?

Skip,
[sub]
[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top