+ Reply to Thread
Results 1 to 8 of 8

Runtime error '28'..... out of stack space solution!!

Hybrid View

  1. #1
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Runtime error '28'..... out of stack space solution!!

    Hey friends!!
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("A4").Value = "GRTP" Then
        Range("A5:P47").EntireRow.Hidden = True
        Range("A127:P164").EntireRow.Hidden = False
    ElseIf Range("A4").Value = "MMIT" Then
        Range("A5:P47").EntireRow.Hidden = False
        Range("A127:P164").EntireRow.Hidden = True
    
    End If
    End Sub
    I have the above code, every thing goes well.. but when i add
    Range ("A1").Value = "ASIA"
    after
    If Range("A4").Value = "GRTP" Then
    Then i have a runtime error '28'... out of stack space and excel shuts down itself..
    What is my problem... can anyone help me with this??

    Thanks

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Runtime error '28'..... out of stack space solution!!

    Is there any other code resides in your workbook?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,461

    Re: Runtime error '28'..... out of stack space solution!!

    You have to disable events before updating the contents of the sheet otherwise the event will fire again.
    As your code does not check what cell is changing the event fires and executes the code every time a change happens.

    Private Sub Worksheet_Change(ByVal Target As Range)
        
        Dim Events As Boolean
        
        If Range("A4").Value = "GRTP" Then
            Events = Application.EnableEvents
            Application.EnableEvents = False
            Range("A1").Value = "ASIA"
            Application.EnableEvents = Events
            Range("A5:P47").EntireRow.Hidden = True
            Range("A127:P164").EntireRow.Hidden = False
        ElseIf Range("A4").Value = "MMIT" Then
            Range("A5:P47").EntireRow.Hidden = False
            Range("A127:P164").EntireRow.Hidden = True
        End If
    End Sub
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Runtime error '28'..... out of stack space solution!!

    Hey sixth sense!! i have a macro but don't have other codes in main sheet..

    Andy Pope,
    It did not help

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Runtime error '28'..... out of stack space solution!!

    Quote Originally Posted by meus View Post
    Hey sixth sense!! i have a macro but don't have other codes in main sheet..
    Andy fixed your issue so try Andy's solution

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,461

    Re: Runtime error '28'..... out of stack space solution!!

    You need to post a file then as it works for me.

  7. #7
    Forum Contributor meus's Avatar
    Join Date
    11-25-2014
    Location
    kathmandu
    MS-Off Ver
    2010/ 2013
    Posts
    287

    Re: Runtime error '28'..... out of stack space solution!!

    Opps!!! It helped actually... i missed one thing...
    Thank you Andy Pope... and thank you sixth sense, you too..
    ..
    Can you explain me Andy, how it helped and how it works???
    Thanks/...

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,461

    Re: Runtime error '28'..... out of stack space solution!!

    I thought I had in my post.

    The event fires every time a cell on the sheet changes. Inside the event you change a cell cause the event to fire again. This keeps happening until it runs out of stack space.

    The code I added turns off the event listening whilst you update the sheet from within the event routine

+ 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. Run-time error '28' Out of stack space
    By pinkpantherksa in forum Excel General
    Replies: 1
    Last Post: 12-13-2012, 06:33 PM
  2. Runtime Error 28 Out of stack space = headache!
    By SportyJim1979 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-21-2012, 09:06 PM
  3. Excel Error: 28 Out of Stack space
    By AinMn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2010, 01:24 AM
  4. Out of stack space error
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-20-2008, 03:47 PM
  5. 'Out of stack space' error on SaveAs
    By Tim in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-22-2005, 01:05 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