Thread: Clear workbook
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Clear workbook

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!