+ Reply to Thread
Results 1 to 15 of 15

Out of Stack space but can use F8 to step through no problem.

  1. #1
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Out of Stack space but can use F8 to step through no problem.

    Hi all 'm back looking for help. I have a sub routine that has started giving me an "Error 28 Out of stack space" and can't figure out why.
    If I run through it using the "F8" step through it works fine but when running in program it gives the error. I have looked through the docs on the error but don't understand why I still get the error when using the suggested workarounds. Can someone please help and explain what's happening and how to correct it? All help is greatly appreciated!

    Here is the Sub Code:

    Please Login or Register  to view this content.
    It is part of another Sub routine to update the current sheet after data entry and all include the applications turn offs listed above in the code.

    Thanks again for any help in explaining or how to fix the issue!!

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Out of Stack space but can use F8 to step through no problem.

    Quote Originally Posted by COURTTROOPER View Post
    It is part of another Sub routine
    I suggest you post all of the code, please.
    Rory

  3. #3
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Out of Stack space but can use F8 to step through no problem.

    See next post
    Last edited by JLGWhiz; 07-08-2019 at 04:52 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Out of Stack space but can use F8 to step through no problem.

    Basically, your machine is running out of memory.

    This error is most often caused by intense use of functions and sub calls (especially when it's nested in multiple layers). But could also be caused by registry error.

    In your case, I'd imagine former to be more likely cause. Try breaking your sub into smaller subs. As memory is freed up when variable/function etc goes out of context (i.e. sub terminates).

    Have a read of link as well.
    https://docs.microsoft.com/en-us/off...space-error-28
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  5. #5
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Out of Stack space but can use F8 to step through no problem.

    cannot edit original input.

    Original message:

    Please Login or Register  to view this content.
    Last edited by AliGW; 07-08-2019 at 05:56 PM. Reason: Original message reinstated.

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Out of Stack space but can use F8 to step through no problem.

    Why am I not able to edit my posts? I get blank edit boxes.

  7. #7
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Out of Stack space but can use F8 to step through no problem.

    Try this

    Please Login or Register  to view this content.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Out of Stack space but can use F8 to step through no problem.

    Quote Originally Posted by JLGWhiz View Post
    Why am I not able to edit my posts? I get blank edit boxes.
    Forum bug - happens indiscriminately. I have reinstated one of your posts containing code. Hope this helps.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Out of Stack space but can use F8 to step through no problem.

    Tx AliGW
    regards, JLG
    Last edited by AliGW; 07-09-2019 at 01:03 AM. Reason: Please don't quote unnecessarily!

  10. #10
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Out of Stack space but can use F8 to step through no problem.

    Thanks JLGWiz that fixed the issue! Can you explain what changing the "Sign.Range(xx) to just .Range(xx)" does to change how the stack is effected please? If I am using extra code I don't need I want to understand how to do it correctly.

  11. #11
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Out of Stack space but can use F8 to step through no problem.

    Can someone please explain:
    Can you explain what changing the "Sign.Range(xx) to just .Range(xx)" does to change how the stack is effected please? If I am using extra code I don't need I want to understand how to do it correctly.

    Thanks to all.

  12. #12
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Out of Stack space but can use F8 to step through no problem.

    It's not just changing Sign.Range() to .Range. But using With statement.

    Code block is...
    Please Login or Register  to view this content.
    Sign is variable that's been set to object. By nesting .Range() inside 'With Sign' statement. You only need to write Sign once in With statement.
    When nested members are preceded by "." it indicates that the member belongs to that object indicated in With block.

    You can read more about it in link below.
    https://docs.microsoft.com/en-us/dot...with-statement

    However, I'm not sure how that impact memory usage. As it still holds same space in memory stack for the variable used.
    Perhaps, by reducing code clutter, it freed up some memory. Or since object property need to be read only once... instead of multiple times... (to my understanding this only improves code execution speed and not memory optimization, but I could be wrong).
    Last edited by CK76; 07-10-2019 at 11:31 AM.

  13. #13
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Out of Stack space but can use F8 to step through no problem.

    I am not sure I can explain it properly. You are using Sign as a sheet Name and as an object variable. This does have an effect on how the processor handles the data as the compiler interprets the code. I know that repeating the variable on each line of code froces the compiler to process the redundant entry over and over, each time distingruishing the variable from the sheet name. That could be causing an internal problem with the processor memory stack. I know that it is not a good practice to use the same text for a name and an object variable, just as it is not good practice to use key words like 'Cell' for a variable. But since they sometimes work, people continue to do it and then wonder what went wrong when problems arise because they used them.
    Last edited by JLGWhiz; 07-10-2019 at 02:47 PM.

  14. #14
    Forum Contributor
    Join Date
    06-06-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    2013
    Posts
    129

    Re: Out of Stack space but can use F8 to step through no problem.

    Thank you both for the explanation and I will read up on your suggestions. I am a novice as you can tell and want to learn better ways of writing code. Thanks again for your help!

  15. #15
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Out of Stack space but can use F8 to step through no problem.

    Happy to assist,
    regards, JLG

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Out Of Stack Space Error With Toggle Button Clicks - One Problem Button
    By Jenn68 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-11-2019, 10:05 AM
  2. [SOLVED] Stack out of Space - asking too much of VBA?
    By creationracing in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-04-2018, 10:47 AM
  3. Out of stack space
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2013, 01:06 AM
  4. [SOLVED] Out of Stack Space
    By Phoenix5794 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-29-2012, 08:44 PM
  5. Out of Stack Space
    By process in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-02-2012, 11:31 AM
  6. out of stack space??
    By adds007 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 02-22-2011, 12:02 PM
  7. Out of stack space problem
    By Fred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2006, 08:15 AM

Tags for this Thread

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