Link to home
Start Free TrialLog in
Avatar of phl
phl

asked on

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 ...
Avatar of cartti
cartti

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 ?
Try opening the sheet with the SHIFT key held down, this will not run any auto-open macros , you can then edit anything.
Avatar of phl

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of cartti
cartti

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, add the name of the module to the syntax to be certain. So...

Application.OnEntry = name of workbook file & "!" & name of module & ".NameOfSub"
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!
Sorry, I've not seen cartti answer.
Avatar of phl

ASKER

Thanks cartti ! (and vboukhar too :) ) . See you later ... :)