title: How do I solve so excel doesn't crash by my code?
body: <p>I have a file which inconsistently crash. The only reliable way for me to make it crash is to copy the file and then when I run my macro (Which is to open a userform) it crashes. If I then use the recovered file instead, it will not crash. But as soon as I save the file again, it will display the same behavior.</p>
  <p>I think i've traced the issue. I have userforms that will open within the 'Master' userform and if I delete a specific userform I can't get excel to crash.
  I've tried to delete all code belogning to that specific userform and that also seems to help.
  My last investigation was to delete a specific part of the code, which seems to be the problem as excel doesn't crash anymore once i've deleted that part of code.</p>
  <p>Note that the code itself shouldn't be the problem as sometimes it works exactly as it should, without any issue at all. I'm starting to think that it's either because of the amount of code, or the amount of mousedown/mouseup events.</p>
  <p>Part 1 of 289:</p>
  <pre><code>Private Sub Block1V1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
      If GameOverStatus = &quot;No&quot; Then
          If Button = 2 Then
              'Rightclick
              Call PutFlag(0, 0)
              Else
                  If Block1V1.Caption = &quot;&quot; Then
                      Block1V1.SpecialEffect = fmSpecialEffectSunken
                      Call Hit(0, 0)
                  End If
          End If
      End If
  End Sub
  Private Sub Block1V1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
      If GameOverStatus = &quot;No&quot; Then
          Block1V1.SpecialEffect = fmSpecialEffectFlat
      End If
  End Sub
  </code></pre>
  <p>As you can see in the code, i'm reffering to &quot;Block1V1&quot;. I have a total of 17x17 = 289 of these blocks with the exact same code, only difference is the numbering in which block it will reference.</p>
  <p>All of that total 5 490 rows of code.</p>
  <p>Do anyone have any idea why this might cause excel to sometimes crash and sometimes work flawless?
  I'm not aware of any limits of how much code can be stored within a Userform or if there is a limit on how many MouseDown/MouseUP event you can have.</p>
  <p>NOTE that excel crashes without any of the above code being run. I don't even need to open the problematic userform for excel to crash.</p>
  <p>NOTE:
  My investigation as to where the issue is was not good. I've been able to reproduce the issue even when that specific userform is deleted.
  However, I also found a bad fix. When I open the workbook, if I save it before I show the first userform it doesn't seem to crash.</p>