Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Reset VBA Code

This is a discussion on Reset VBA Code within the Excel Questions forums, part of the Question Forums category; When I execute a macro, and if during the macro execution I press the "Esc" key, the execution stops and ...

  1. #1
    New Member
    Join Date
    Dec 2005
    Posts
    21

    Default Reset VBA Code

    When I execute a macro, and if during the macro execution I press the "Esc" key, the execution stops and I get a Microsoft Visual Basic window with the message that code execution has been interrupted with buttons to Continue, End, Debug and Help. If I click the "End" button, the window closes and Excel is at rest - which seems to be some sort of Reset process.

    I have a need to execute that process while Excel is at rest.
    Is there any way to code the process in VBA?

    TIA

    JerryD

  2. #2
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    65,646

    Default

    Jerry

    What exactly do you mean?

    What 'Reset' process are you referring to and what are you trying to achieve?
    If posting code please use code tags.

  3. #3
    New Member
    Join Date
    Dec 2005
    Posts
    21

    Default

    Norie:

    When I execute a macro of mine, it slows down each succeeding time I execute it until it gets real slow. I don't know exactly what is happening but somehwere in the past, I recall that Excel uses up resources which it does not return for use. Maybe that is what's happening.

    In my case, when I interrupt this macro with "Esc" and get the interrupt window and click the "End" button, the macro will then execute at it's most fast speed again (until I run it a few times). I also get this desired result by pressing "Esc" and the clicking "Debug" which sends me to the VBA editor with the "Yellow" line which forces me to Run/Reset. (Also, exiting Excel and coming back in will allow the macro to run at it's most fast speed)

    I would like to be able to execute whatever this reset is without having to inturrupt with "Esc" and clicking "End". Right now, if the macro gets too slow, I just periodically press "Esc" during execution and Click "End".
    Then rerun the macro. If I could code that process, I might be able to execute it on the fly to prevent the slow down to begin with.

    Whatcha think?


    JerryD

  4. #4
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    65,646

    Default

    Jerry

    I think it would be useful to see your code.

    Perhaps we could take a look at it and see why it's slowing down.

    PS I don't think this 'Reset' actually exists, could be wrong though.
    If posting code please use code tags.

  5. #5
    New Member
    Join Date
    Dec 2005
    Posts
    21

    Default

    Sorry, I can't send the code. But the macro works fine and does all it's supposed to do. It just slows down with continued use.

    But I can further describe the reset process I am speaking about (I am using Excel2000). Do you personally have a macro which requires enough seconds to execute that you could press the "Esc" key before the execution is finished? If so, execute it and press the "Esc" key before it is finished. I know that there is some code which may not halt with the "Esc" key but mine does. When it stops (interrupted), the window that is displayed has 4 buttons for selection. I click the "End" button and the interrupt window closes. (I have interrupted the macro and stopped the process)

    Also, instead of clicking the "End" button, I can click "Debug" and the VBA editor is opened (and in my case, a line in the macro is yellowed out). If I then click "Run" in the menu bar and click the "Reset" selection in the drop down "Run" menu, it will also close the interrupt window and also apparently "resets" whatever it is that is slowing down my macro. Since I am selelcting "Reset" as a command in the "Run" Menu, that is why I am calling it a reset condition.

    It may not be a reset but maybe just a termination process. But it is that process which I would like to code if possible.

    Excel suspends code execution if you really have an execution error and forces you to go to the VBA editor and do the Run/Reset command "and a code correction". I don't have a code error but I would like to do that Run/Reset anyway, at my convenience, to eliminate my slow down problem.

    JerryD

  6. #6
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    65,646

    Default

    Jerry

    If you can't post the code I can't really see how we can help.

    Could you not even outline what the code is doing?

    As far as I know Reset just stops execution.
    If posting code please use code tags.

  7. #7
    Board Regular PA HS Teacher's Avatar
    Join Date
    Jul 2004
    Location
    Rochester, NY
    Posts
    2,838

    Default

    Jerry,

    Any number of code contructs could lead to your code "slowing down" and I am almost certain that that the VBA editor has nothing to do with it. It is not necessary to "send" your code anywhere. You can simply copy and paste the code into your post. (providing you surround it with code tags. If necessary you can post a representative sample of your code, or replace any proprietary information.

    Norie is one of the best code people we have here, but without some code, there is nothing that can be done.
    Recent Draftee
    www.mrexcel.com/board2/viewtopic.php?t=199272
    Recently came across a Free 1 GB Storage/File Sharing Site www.box.net

  8. #8
    New Member
    Join Date
    Dec 2005
    Posts
    21

    Default

    OK. I appreciate your replies. I guess it must be a communications thing. My macro code really has nothing do do with my inquiry. I only used the macro and what I was experiencing, as an example to show or explain what I would like do.

    So, just assume I had not mentioned my macro at all, or what it was doing. Now, is there any way to code the following procedure: (I would like to be able to execute the following steps, preferrably with a macro rather than having to do the steps manually).

    From Excel:
    1. Click Tools
    2. Point at Macro
    3. Click Visual Basic Editor
    4. In the VBA Editor menus, Click the Run menu
    5. In the drop-down, Click the Reset command
    6. Return to Excel

    Or, any other macro execution which would "do what steps 1-6 do". Turning the Macro Recorder ON does not record anything when I do those steps. And, if you just do steps 1-6, it appears that you have done nothing. However, I can assure you, something in Excel gets reset because when I manually do those steps, Excel makes a "distinct" change (I can see it in the execution time of my macro).

    Microsoft would not have the VBA Run/Reset command in the menu if it didn't do something. It may not be possible to code it but Excel recognizes when you click Reset. That's all I'm asking. Is it possible to execute that Reset with code (or anything else equivalent in code) rather than having to manually click thru the steps?

    Thanks for your help.

    JerryD

  9. #9
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    65,646

    Default

    Jerry

    Of course it does something, and as far as I'm aware it just stops code execution.
    If posting code please use code tags.

  10. #10
    VoG
    VoG is offline
    MrExcel MVP
    Moderator
    VoG's Avatar
    Join Date
    Jun 2002
    Location
    127.0.0.1
    Posts
    62,242

    Default

    As well as stopping code execution a Reset will also reset all public variables. This can also be achieved through an End (not End Sub etc.) statement.

    However I'm still curious as to why your macros would slow down and why you feel unable to post the code

Page 1 of 2 12 LastLast

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com