I have a worksheet with many cells that use CUBEVALUE
to load data. These cubevalues point to some common cells, which are the main parameters for the cubevalue query. With my VBA script, I change these common parameters and hence all the cubevalues are reevaluated. I want to wait until all the cubevalues are reevaluated. How can I do that?
I tried this:
Sub WaitUntilCalculationDone()
Dim waittime As Integer
waittime = 0
Do Until Application.CalculationState = xlDone
Application.Wait Now + TimeValue("0:00:02")
waittime = waittime + 2
Loop
Debug.Print "waited " & CStr(waittime)
End Sub
This code waits for the Application.CalculationState
to change to xlDone
before finishing the script. However, it's not working as expected. How can I modify this code to wait until all the cubevalues are reevaluated? This question is related to my previous question: Saving pomegranate Bayesian Network models