My son (15 y) is studying pendulum at school, physics lessons. I am trying to help him with a simulated pendulum in Excel, using 2 points chart, one fix (where the \"cord\" of
Sounds like a DoEvents
problem. Just put DoEvents in your code like so:
...
ActiveSheet.ChartObjects("Chart 1").Chart.Refresh
DoEvents
Sleep (50)
...
It's 2020 and am running Excel 2016 for MAC. I put this subroutine in my code (combined various items I found on the web) and got the chart to update each time the sub is called (be sure to define a cell in your worksheet as "stepper" so the counter data can be stored and updated). My chart was auto-named "chart 8" by excel:
Sub ChartAnimation3()
Dim i As Double
For i = 0 To 1000 Step 500
ActiveSheet.Range("Stepper") = i
DoEvents
DoEvents
Next
ActiveSheet.ChartObjects("Chart 8").Chart.Refresh
ActiveSheet.ChartObjects("Chart 8").Activate
ActiveChart.Refresh
DoEvents
End Sub
There might be some items not needed in this code, but I'm a novice, and it worked, so I am satisfied.