I'm not sure if I follow. You want to run a macro when you close the workbook? If so, you could use:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'\Your Macro\
End Sub
You would have to do this under workbook and not under modules.
I'm sorry I have not managed to explain may problem properly.
This is what I need to know : the macro I've made opens a new worksheet, and then automatically closes itself, leaving only this new worksheet(which don't contains any macro).
What should I do to close this new worksheet?
I think that I must use a dos command...
Thanks!
If you set up some pre-program or splash page to run on startup but did not build Exit code into your startup macro code, you can generally stop a running macro with the "Esc" Escape key. If this is the case I would suggest you add a control button or exit code to your startup macro, to avoid this situation.
If the escape key works and stops your macro you can code a button with:
Application.SendKeys("{ESC}")
If escape did not work post your code and we will figure out an exit code. JSW