update a single chart multiple times as a macro runs

glad_ir

Board Regular
Joined
Nov 22, 2020
Messages
143
Office Version
  1. 2010
Platform
  1. Windows
Hello,

Hoping somebody can help me please.

Is there a command I can include in a macro that will update a chart?

I have a macro that adds data into a worksheet and the added data is used in a Chart (Chart name is Chart 17). The macro adds 1 data point at a time, pauses for 1 second then adds the next data point and so on. Currently my chart only updates once the macro finishes. Is there a way to force the chart to update after each data point is added?

Any help is much appreciated.

Thank you,
Iain
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Inside your timer loop:

DoEvents

will allow Excel to update the chart.
Hi Stephen,

Thank you very much for replying. I have added "DoEvents" into the code as 3 places but it does seem to make a difference. The code runs as before and the chart doesn't update until the end of the code. Do I need to add anything else?

thanks, Iain
 
Upvote 0
Here's a simple example of what I had in mind, which works for me in Excel 2010: Draw graph

1611530582028.png


VBA Code:
Sub DrawGraph()

    Dim t As Double
    Dim i As Long
  
    For i = 2 To 12
        Range("A2:A" & i).Name = "x"
        Range("B2:B" & i).Name = "y"
        t = Timer + 1
        Do While Timer < t
            DoEvents
        Loop
    Next i

End Sub

How are you adding data points? Coding your 1 second pauses?
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top