Thread: Clear workbook
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Clear workbook

For future reference, these 3 lines...

Worksheets.Add befo=Worksheets(1)
Worksheets.Add befo=Worksheets(1)
Worksheets.Add befo=Worksheets(1)


can be replaced by this single line...

Worksheets.Add Befo=Worksheets(1), Count:=3

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Better to start with fresh, clean, sheets rather than try to launder the
old
ones:

Sub cleanup()
Worksheets.Add befo=Worksheets(1)
Worksheets.Add befo=Worksheets(1)
Worksheets.Add befo=Worksheets(1)
n = Worksheets.Count
For i = n To 4 Step -1
Application.DisplayAlerts = False
Sheets(i).Delete
Next
End Sub

--
Gary''s Student - gsnu200830


"Lucile" wrote:

Hi all,

I need to add a piece of code at the beginning of my program that checks
if
the workbook is empty or not (I just want 3 blank sheets). And if it is
not
empty (charts, sheets with data...) it needs to clear/delete everything
and
keep only 3 blank sheets....

Thanks a lot!