View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default quitting worksheet then excel if....

Try something like:

Sub bks()
Dim i As Integer
Dim wkb As Workbook
For Each wkb In Application.Workbooks
If wkb.Name < "PERSONAL.XLS" Then
i = i + 1
End If
Next wkb
If i 1 Then
ThisWorkbook.Close True
Else
ThisWorkbook.Save
Application.Quit
End If
End Sub

Hope this helps
Rowan

JNW wrote:
I have a program used to fill out forms in our department. When logging out
of the program (commandbutton) I can either close the workbook, or quit the
application.

What I would like to know: Is there a way to check to see if there are any
other workbooks open? If yes then close my program workbook. If no then
quit excel.

Thank you