Solved

How to stop a macro Excel 5.0

Posted on 1998-11-26
8
282 Views
Last Modified: 2008-01-09
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 ...
0
Comment
Question by:phl
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 2

Expert Comment

by:cartti
ID: 1614667
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
 

Expert Comment

by:hammerts
ID: 1614668
Try opening the sheet with the SHIFT key held down, this will not run any auto-open macros , you can then edit anything.
0
 

Author Comment

by:phl
ID: 1614669
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 2

Accepted Solution

by:
cartti earned 100 total points
ID: 1614670
Use this syntax to avoid Excel being confused as to what macro to use:

Application.OnEntry = name of workbook file & "!NameOfSub"
0
 
LVL 2

Expert Comment

by:cartti
ID: 1614671
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
 
LVL 5

Expert Comment

by:vboukhar
ID: 1614672
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
 
LVL 5

Expert Comment

by:vboukhar
ID: 1614673
Sorry, I've not seen cartti answer.
0
 

Author Comment

by:phl
ID: 1614674
Thanks cartti ! (and vboukhar too :) ) . See you later ... :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel 2013 spreadsheet opens without custom margins 13 21
Automatic sort formula 8 54
Activation for Microsoft Office for Mac 2016 3 38
Office 2016 Temp Files 3 31
Introduction Perhaps more familiar to developers who primarily use VBScript than to developers who tend to work only with Microsoft Office and Visual Basic for Applications (VBA), the Dictionary is a powerful and versatile class, and is useful …
Introduction It seems that at least a couple of times per month, I answer a question that requires automating Outlook from another Microsoft Office application, usually (although not always) to send one or more email messages.  For example: …
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question