+ Reply to Thread
Results 1 to 4 of 4

Error message 'Running out of stack space'

  1. #1
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    807

    Error message 'Running out of stack space'

    Hi

    I am trying to hide some columns in the range AC:BB in the sheet Weekly Report Data which has the value "H" is in some cells in the range AC2:BB2. The macro keeps running until I get the 'out of stack space' message so I assume my code is telling it to do something else. Can someone point out where my code is failing?


    [Private Sub Worksheet_Activate()
    Dim c As Range

    Application.ScreenUpdating = False
    Sheets("Weekly Report Data").Select
    For Each c In Range("AC2:BB2")
    c.EntireColumn.Hidden = (c.Value = "H")
    Next c
    Sheets("Weekly Report").Select
    Range("c21").Select
    Application.ScreenUpdating = True

    End Sub[/HTML]

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Error message 'Running out of stack space'

    The code is in a worksheet Activate event - and I'll assume one of the worksheets that is activated is the one running the code. That'll cause the Activate event to fire again, and it will activate the worksheet again, firing the event again, and so on. Eventually, you run out of Stack Space as none of recursively called events has a chance to exit...

    Untested, but something lie this may work

    Please Login or Register  to view this content.
    No switching worksheets so no recursive calls to the Activate event.
    Last edited by cytop; 03-17-2017 at 09:07 PM.

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Error message 'Running out of stack space'

    Hi !

    Within a worksheet activate event do not activate any other worksheet !
    As a good code does not need to activate / select anything …
    Just respect Excel model object : Workbook / Worksheet / Range …

  4. #4
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    807

    Re: Error message 'Running out of stack space'

    Your code worked perfectly, and I think I can understand your explanation. Thank you.

+ 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] How do i solve error '28': Out of stack space
    By Melissa Camp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2015, 05:42 PM
  2. [SOLVED] Error 28 Stack Space
    By scrabtree23 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2015, 09:58 AM
  3. VBA Out of Stack Space Error 28
    By alexcapewell in forum Excel General
    Replies: 9
    Last Post: 10-13-2015, 07:01 AM
  4. Out of stack space error
    By lazyengineer in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-10-2015, 02:24 PM
  5. Run Time Error 28: Out of Stack Space
    By Shanahan0 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2013, 10:42 AM
  6. [SOLVED] In code using usedrange Error message 1004 Out of stack space?
    By Freakazoid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2012, 04:09 PM
  7. Out of stack space error
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-20-2008, 03:47 PM

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