Thread: Clear workbook
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Clear workbook

Why not just start a new workbook with 3 worksheets?

Option Explicit
Sub testme()
Dim NewWkbk As Workbook
Dim CurSheetsInWorkbook As Long

CurSheetsInWorkbook = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 3
Set NewWkbk = Workbooks.Add
Application.SheetsInNewWorkbook = CurSheetsInWorkbook

'then work with newwkbk

End Sub

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!


--

Dave Peterson