I searched Google until page 10, but could not find a solution for this. I have a loop in VBA, but want it to wait before proceeding until the sheet has recalculated.
What most people suggest is employ DoEvents. However, that does not work for me.
Here is my code so far, which does not wait until the sheet calculated:
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
Does anyone know a different solution than this one?:
Application.Calculate
If Not Application.CalculationState = xlDone Then
DoEvents
End If