Private Sub Workbook_BeforeClose(Cancel As Boolean)
If thisworkbook.Name = "采购入库.xlsm" Then
Workbooks("库存盘点表.xlsm").Close
else
Workbooks("库存盘点表.xlsm").Close
Workbooks("月结销售盈利表.xlsm").Close
End If
End Sub
'这样合并
Private Sub Workbook_BeforeClose(Cancel As Boolean)
For Each Wb In Workbooks
If Wb.Name = "采购入库.xlsm" Then
Wb.Close
End If
If Wb.Name <> "月结销售盈利表.xlsm" Then
Wb.Close
End If
Next
End Sub
'其实也可以简单点
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'如果需要保存,就先执行保存操作
Application.quit
End Sub