+ Reply to Thread
Results 1 to 10 of 10

Stack Overflow

Hybrid View

  1. #1
    Registered User
    Join Date
    03-17-2005
    Posts
    19

    Stack Overflow

    I believe I'm running into an overflow stack with a fairly large MACRO program. Will chopping the VBA MACRO into call routines reduce the stack size of the MACRO?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Stack Overflow

    Perhaps some unintended recursion?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-17-2005
    Posts
    19

    Re: Stack Overflow

    The MACRO behaves differently for different individuals. I seem to lose the ability to properly run a getsaveasfilename, another individual gets stack error or reference to another MACRO error, etc. The error isn't cosntant - seems to differ randomly.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Stack Overflow

    I'd say if you have procedures with over 100 or so lines of code, you have something that will be very hard to debug and maintain.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Stack Overflow

    Hello DonHuff,

    Usually when you start getting random errors in VBA, Excel is running low on resources. Before Windows 2000 this was a major problem. The NT file system helped relieve this issue but not eliminate it. Instead of the resources memory being set to predefined amounts, the resources are basically unlimited. I emphasize "basically". Under the NT memory management system, resources are not limited, as long as you have enough physical memory (RAM) or virtual memory (disk space). The Windows NT memory system allocates resources dynamically. As long as the memory is available, your application can use it.

    So depending on your program's size and what other programs you have running and memory, you could be running low on resources. To see how you are doing, press CTRL+ALT+DEL to bring up the Task Manager. Click on the tab Performance. You can then see what your system is using.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Registered User
    Join Date
    03-17-2005
    Posts
    19

    Re: Stack Overflow

    Between 1 and 51% while MACRO runs. Will breaking MACRO into subroutines lower system usage?

  7. #7
    Registered User
    Join Date
    03-17-2005
    Posts
    19

    Re: Stack Overflow

    I use copy and paste (always turn them off), delete rows, create formulas in cells, sort. Are these general events or specific (in other words are there several types of actions/commands that are Worksheet Change and/or SelectionChange events or are they the events themselves?)

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Stack Overflow

    Hello DonHuff,

    Events happen in response to user or system actions and sometimes can be triggered by code. Many objects have event code modules that allow you to write specific code for an object's event, say like when it is clicked.

    The Worksheet is an object that responds to many events. Two of these are the Change event, which happens whenever a cell's value is changed, and the SelectionChange, which happens each time you move the mouse to another cell and select it.

    An easy way to check for Worksheet event code is to do the following...
    1. Open your Workbook and Right Click on the Worksheet's Name Tab
    2. Left Click on View Code in the pop up menu.
    3. On the right side you will see the Code Window. Any event code will appear here.

  9. #9
    Registered User
    Join Date
    03-17-2005
    Posts
    19

    Re: Stack Overflow

    I currently have recalculation set to manual in the spreadsheet. What else should I do to make sure I've closed out change events?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1