![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Mike Golding
Posts: 71
|
I run a Macro from a button to close Excel which is OK when I have only one file open. I can't create a Macro to close just the current file. (With the offer to save)Some help would be great, thanks.
|
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Activeworkbook.Close Ivan |
|
|
|
|
|
|
#3 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
...Or
Sub CloseOrQuit() Dim IwbCount As Integer On Error Resume Next IwbCount = 2 If Workbooks("Personal.xls") Is Nothing Then IwbCount = 1 End If On Error GoTo 0 If Application.Workbooks.Count > IwbCount Then ActiveWorkbook.Close Else Application.Quit End If End Sub _________________ Kind Regards Dave Hawley OzGrid Business Applications Microsoft Excel/VBA Training If it's Excel, then it's us! [ This Message was edited by: Dave Hawley on 2002-03-09 01:35 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|