How to stop a macro Excel 5.0

I 've got a Auto_open macro in a sheet. I open another sheet of the same type (with the same Auto_open macro). Then I try to close the first one. At the moment I use the second one, the first one is reopened, presumably to execute its macro. How to prevent that ? I tried to do an "End" command, but to no avail ...
phlAsked:
Who is Participating?
 
carttiConnect With a Mentor Commented:
Use this syntax to avoid Excel being confused as to what macro to use:

Application.OnEntry = name of workbook file & "!NameOfSub"
0
 
carttiCommented:
Can you clarify your question ? This is how I understood it. You have an Auto_Open macro in one Workbook. In the code of that macro, you open another workbook. You then close the first workbook. From when you say 'At the moment I use the second on....' I've lost you.

Is there only one macro which is in the first workbook, or are there more ?
0
 
hammertsCommented:
Try opening the sheet with the SHIFT key held down, this will not run any auto-open macros , you can then edit anything.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
phlAuthor Commented:
In fact I want the macro to stop by itself, with no human intervention. More information is needed i see :) :
Each WORKBOOK I use contains the same macros (Auto_open and others). Thess macros are :
Sub Auto_open()
    Application.OnSheetActivate = "Init"
End Sub

and calls :

Sub Init()
    Application.OnEntry = "NameOfSub"
End Sub

(...)

Then each time I enter a value, the "NameOfSub" macro is used. But I would like that each workbook uses its own macro instead of using the macro belonging to the first opened workbook.
0
 
carttiCommented:
Sorry, add the name of the module to the syntax to be certain. So...

Application.OnEntry = name of workbook file & "!" & name of module & ".NameOfSub"
0
 
vboukharCommented:
You have just use more clear description of your sub:
Sub Auto_open()
Application.OnSheetActivate = ActiveWorkbook.Name & "!Init"
End Sub

Sub Init()
Application.OnEntry = ActiveWorkbook.Name & "!NameOfSub"
End Sub
Check it!
0
 
vboukharCommented:
Sorry, I've not seen cartti answer.
0
 
phlAuthor Commented:
Thanks cartti ! (and vboukhar too :) ) . See you later ... :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.