[VB] updating charts

Unleash

New Member
Joined
Apr 15, 2011
Messages
13
I know this is an "vba" forum, but i got great help here earlier, and I hope you can help me with this vb question as well.

I am trying to change data points in a serie in a chart on a userform. The effect i am looking for is the same you have in Windows taskmanager (the CPU perfomance charts).

This is how far i am. It is a simple test to get the hang of it.

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Pnt1 = 2
        Chart1.Series.Item("A").Points(0).SetValueXY(0, Pnt1)
        Chart1.Update()
    End Sub
Problem is that the point(0) which currently contains 0,0 isnt set to 0,2. And the chart isnt updated.

So the question is any idea on how to do this, or where i can find an answer?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Right, so first this:

The "Yvalues" is an array. It took me some searching to figure out why it won't simply work if you use:
Code:
Chart1.Series.Item("A").Points(0).YValue() = 2

You need to specify which item within the array you want to change so:
Code:
Chart1.Series.Item("A").Points(0).YValue(0) = 2

Will work.
I changed to code into this:
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Chart1.Series.Item("A").Points(0).YValues(0) = 2
        Chart1.Update()
    End Sub

Now the Yvalue changes into 2 but the chart doesnt show any change... If I use that technique with the xValue it will change... Any thoughts??
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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