You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VBA循环迭代至约700次时Excel崩溃问题求助

VBA循环迭代数千次时Excel崩溃问题

我编写的VBA代码LottoSearch在循环迭代至数千次(比如上限设为1000)时会导致Excel崩溃,仅当循环上限设为650或更低时能正常运行。我已经确认使用的是最新版Microsoft 365 Excel,内存和CPU资源充足,同时尝试了商务版和家庭版Excel,问题依旧。请问是否有其他人遇到过此类问题?

Sub LottoSearch()
   Dim stopRunUp As Integer
   stopRunUp = 0
    For i = 2 To 1000

     lottoNum = Cells(i, 3).Value

      If lottoNum = 3957481 Then
        Cells(2, 6).Value = Cells(i, 1).Value
        Cells(2, 7).Value = Cells(i, 2).Value
        Cells(2, 8).Value = lottoNum
        MsgBox ("Congratulations " + Str(Cells(2, 6).Value) + " " + Str(Cells(2, 7).Value))
      End If

      If lottoNum = 5865187 Then
       Cells(3, 6).Value = Cells(i, 1).Value
       Cells(3, 7).Value = Cells(i, 2).Value
       Cells(3, 8).Value = lottoNum
      End If

     If lottoNum = 2817729 Then
       Cells(4, 6).Value = Cells(i, 1).Value
       Cells(4, 7).Value = Cells(i, 2).Value
       Cells(4, 8).Value = lottoNum
     End If

     If lottoNum = 2275339 And stopRunUp = 0 Then
       Cells(5, 6).Value = Cells(i, 1).Value
       Cells(5, 7).Value = Cells(i, 2).Value
       Cells(5, 8).Value = lottoNum
       stopRunUp = 1
     End If

     If lottoNum = 5868182 And stopRunUp = 0 Then
       Cells(5, 6).Value = Cells(i, 1).Value
       Cells(5, 7).Value = Cells(i, 2).Value
       Cells(5, 8).Value = lottoNum
       stopRunUp = 1
     End If

     If lottoNum = 1841402 And stopRunUp = 0 Then
       Cells(5, 6).Value = Cells(i, 1).Value
       Cells(5, 7).Value = Cells(i, 2).Value
       Cells(5, 8).Value = lottoNum
       stopRunUp = 1
     End If

   Next i

 End Sub

内容的提问来源于stack exchange,提问作者Andrew Jessberger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 08:02:47