View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default close all worksheets accept the active one

One way:

Call the function below like so (use true or false to save each one or not):

Sub Test()
Call FilesDeActivate(False)
End Sub


Public Function FilesDeActivate(argSaveChanges As Boolean)
Dim wrkBooks As Workbooks
Dim wrkBook As Workbook
Set wrkBooks = Application.Workbooks
For Each wrkBook In wrkBooks
If UCase(wrkBook.Name) < UCase(ThisWorkbook.Name) Then
Workbooks(wrkBook.Name).Close SaveChanges:=argSaveChanges
End If
Next wrkBook
End Function


"S Himmelrich" wrote:

I've not seen anything on this, but would like to close all opened
worksheets accept the one that is current active - any thoughts on
this?