1
我搜索谷歌,直到第10頁,但找不到解決方案。 我在VBA中有一個循環,但希望它在繼續之前等待表格重新計算。 大多數人建議使用DoEvents。但是,這對我不起作用。暫停VBA循環,直到表格被重新計算
這裏是我到目前爲止的代碼,不等到計算表:
Sub Replaceifrebalance()
Dim x As Integer
NumRows = Range("CF16", Range("CF16").End(xlDown)).Rows.Count
Range("CF16").Select
For x = 1 To NumRows
If Range("CF" & x).Value > 0 Then
Range("AW15:BF15").Select
Application.CutCopyMode = False
Selection.Copy
Range("AW1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AW" & 1 & ":BF" & 1).Copy Worksheets("Timeseries").Range("BI" & x & ":BR" & x)
Application.Calculate
If Not Application.CalculationState = xlDone Then
DoEvents
End If
End If
Next
End Sub
有誰比現在這一個?:
Application.Calculate
If Not Application.CalculationState = xlDone Then
DoEvents
End If
任何幫助不同的解決方案是極大的讚賞。