VBA help: Workbook A calls macro on workbook B that closes Workbook A and continues

ks11

New Member
Joined
Jan 26, 2013
Messages
1
Hello guys,

I have this problem exemplified in the picture bellow.
2eqfgqp.jpg

The problem is: when I close workbook A, the macro sub B stops running.

I tried this codes:
Code:
Sub A()
    Workbooks("WorkbookB.xlsm").Close
    (Call other subs)
End Sub

Code:
Sub B()    
    [B]Workbooks("[COLOR=#574123]WorkbookA[/COLOR].xlsm").Close*[/B]
    (Call other subs)
    Application.Run "WorkbookA.xlsm!A"
End Sub

* last line executed

Can anyone help me, please?

Thanks in advance.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Since Sub A is the Parent Sub in Workbook A, when workbook A closes, it effectively invokes an Exit Sub on Sub B in Workbook B. I believe you would have better luck if you put your Sub procedures in an XLA file and ran them like an Add In.
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,973
Members
452,540
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top