Updating data series in chart by VBA

cams88

New Member
Joined
Mar 23, 2020
Messages
21
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I'm trying to update a new series in my chart but my macro doesn't work:

My macro copy this chart:
1591029842585.png

ActiveSheet.ChartObjects("Wykres_Populacja").Activate
ActiveSheet.ChartObjects("Wykres_Populacja").Copy
Range("K43").Select
ActiveSheet.Paste
With ActiveChart
.Parent.Name = "Wykres_X"

to a new cell "K43" and to this point macro works, but I have problem with updating chart series (I need 2 series for cells C3 and D3)- this part doesn,t work:

Set Seria = ActiveChart.SeriesCollection.NewSeries
With Seria
.Name = Range("c1")
.Values = Range("c3")
.Name = Range("d1")
.Values = Range("d3")
End With

data for charts:
1591030535031.png


I will be very grateful for any help.
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Watch MrExcel Video

Forum statistics

Threads
1,114,655
Messages
5,549,254
Members
410,905
Latest member
Extjel
Top