1
當我運行下面的代碼時,爲什麼我的用戶窗體顯示「Not Responding」?我一直在試圖解決它,但尚未解決。宏運行時VBA userform是「Not Responding」
其實它有時會起作用。我認爲這個問題與屏幕更新有關。
' The input button in Sheet1
Sub Rectangle1_Click()
'Remember time when macro starts
StartTime = Timer
' To improve speed and performance
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
' Show the userform
UserForm1.Show vbModeless
UserForm1.Label1.Caption = "Calculation in progress ... " & vbNewLine & "Please be patient"
UserForm1.Label1.Font.Size = 12
UserForm1.Top = (Application.Height/2) - (UserForm1.Height/2)
UserForm1.Left = (Application.Width/2) - (UserForm1.Width/2)
UserForm1.CommandButton1.Visible = False
UserForm1.Repaint
Call Insert_RawData
'Determine how many seconds code took to run
SecondsElapsed = Round(Timer - StartTime, 2)
UserForm1.Label1.Caption = "This code ran successfully in " & SecondsElapsed & " seconds"
UserForm1.CommandButton1.Visible = True
' Return back to the original settings
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationSemiautomatic
End Sub