当我单击按钮运行我的代码时,我会看到蓝色的加载圆圈,如果我等待大约 150 秒,我的代码就会运行,有时会进入“无响应”模式,并且所有内容都会正确输出。但是,如果我单击按钮启动代码并等待 10 秒,然后单击窗口并强制其进入“无响应”模式,我的代码将在大约 30 秒内完成所有正确的输出。
Option Explicit
Option Base 1
Private Sub CommandButton1_Click()
Dim loadtypemax As Single, column As Single, row As Single
Dim loadtype As String, number As String
Dim loadcombosmax As Single
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
loadtypemax = ((Cells(Rows.count, "L").End(xlUp).row))
loadcombosmax = ((Cells(Rows.count, "E").End(xlUp).row))
column = 6
For row = 2 To loadcombosmax
If Cells(row, column) > 0 Then
number = Cells(row, column)
loadtype = Cells(row, (column - 2))
If number = "" Then …Run Code Online (Sandbox Code Playgroud)