+ Reply to Thread
Results 1 to 4 of 4

Run Time Error 28: Out of Stack Space

  1. #1
    Registered User
    Join Date
    01-08-2013
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    1

    Question Run Time Error 28: Out of Stack Space

    Dear all,

    I am trying to put together a macro that is deliberately recursive. The purpose of the macro is to compare a list of 4,000 odd supplier names with a larger list of 340,000 where I am looking for partial matches. This macro is designed to go through the list of 4000 names using the =search function in Excel and then determine whether it is a match or not. The macro will run through approx. 50 items before return wit h the error "Run Time Error 28: Out of Stack Space". I have set the Application.EnableEvents = False and this still happens. All assistance welcome.

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    ' Keyboard Shortcut: Ctrl+q
    '

    Do While ActiveCell.Value <> ""
    Application.Calculation = xlCalculationManual
    ActiveCell.Offset(0, 4).Select
    Selection.End(xlDown).Select
    Selection.Copy
    Selection.End(xlUp).Select
    ActiveCell.Offset(0, -4).Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, 4).Select
    Selection.End(xlDown).Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Selection.End(xlUp).Select
    ActiveCell.Offset(0, -4).Select
    ActiveCell.Offset(1, 1).Select
    Calculate
    Application.Run "Macro3"
    Loop


    End Sub


    Sub Macro2()


    Do While ActiveCell.Value <> ""
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    If Selection.Value = "end" Then
    ActiveCell.Offset(-1, 0).Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(0, -1).Select
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Application.Run "Macro1"
    Else

    End If
    If Selection.Value > 0 Then
    ActiveCell.Offset(0, -1).Select
    Selection.Copy
    ActiveCell.Offset(0, -1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Offset(1, 1).Select
    Else
    ActiveCell.Offset(1, 0).Select
    End If
    Loop

    End Sub

    Sub Macro3()

    Selection.End(xlDown).Select
    If Selection.Value = 0 Then
    Selection.End(xlUp).Select
    ActiveCell.Offset(0, -1).Select
    Application.Run "Macro1"
    Else
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Select
    Application.Run "Macro2"
    End If

    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Run Time Error 28: Out of Stack Space

    Your code does not seem to have any match or find function. All you have is select and copy

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,378

    Re: Run Time Error 28: Out of Stack Space

    Welcome to the forum.

    To comply with the forum rules, you should add Code Tags to your macro examples listed above.

    That done, it would be helpful to see those macros in a sample workbook, as it is difficult to determine the layout, structure and content from your description.

    Clearly, this cannot be the full data set, nor should it contain sensitive information. But it would be useful to se some typical examples and your expected outcome.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,378

    Re: Run Time Error 28: Out of Stack Space

    @AB33: good point.

    And, unless you have any worksheet events, you do not need to Disable or Enable Event Handling.

    Regards, TMS

+ 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