ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If not then (https://www.excelbanter.com/excel-programming/408062-if-not-then.html)

Helmut

If not then
 
I have the following statement:

With...
....
....

If Not IsError(.Cells(lr, "r")) Then Application.Run "Office_Payroll_2"

....
....
End with

After it Runs the Macro "Office_Payroll_2" it continues in the current Macro.
But I want it to "Exit the Current Macro after running "Office_Payroll_2"
and close all open workbooks without saving.
what do I need to add?


Jim Cone

If not then
 

Sub EmptyTheBag()
'With...
Dim WkBk As Excel.Workbook
If Not IsError(.Cells(lr, "r")) Then
Application.Run "Office_Payroll_2"
For Each WkBk In Excel.Workbooks
If Not WkBk Is ThisWorkbook Then
WkBk.Close savechanges:=False
End If
Next
ThisWorkbook.Close savechanges:=False
Exit Sub
End If
'End With
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Helmut"
wrote in message
I have the following statement:

With...
If Not IsError(.Cells(lr, "r")) Then Application.Run "Office_Payroll_2"
End with

After it Runs the Macro "Office_Payroll_2" it continues in the current Macro.
But I want it to "Exit the Current Macro after running "Office_Payroll_2"
and close all open workbooks without saving.
what do I need to add?



All times are GMT +1. The time now is 12:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com