Christian_Ku
Board Regular
- Joined
- Sep 10, 2007
- Messages
- 102
Hello,
Currently I'm working in an excel file that contains a lot of charts. I want to write a macro that changes the source data of every serie in every chart. It only needs to add extra rows. But as every series has different columns where they get the data from, how can I change the rows without changing the columns?
This is what I've written so far:
As you can see I've tried two things, first I tried to change the string of the source data, however this meant that every series would have C and E as their source data. So I wanted to retrieve the x and y values in string format. This does not work yet, it returns an array with the values of all the entries in the series source data. From that array I can not retrieve the column where the data came from.
Help much appreciated
Currently I'm working in an excel file that contains a lot of charts. I want to write a macro that changes the source data of every serie in every chart. It only needs to add extra rows. But as every series has different columns where they get the data from, how can I change the rows without changing the columns?
This is what I've written so far:
Code:
Sub ammend_datarange_series_all_charts()
Dim start_cell As String, end_cell As String
Dim chart_tot As Integer, c As Integer, s As Integer
chart_tot = Charts.Count
start_cell = InputBox("Start Cell", "Only give Row number")
end_cell = InputBox("End Cell", " Only give Row number")
For c = 1 To chart_tot
series_tot = Charts(c).SeriesCollection.Count
For s = 1 To series_tot
x_values = Charts(c).SeriesCollection(s).XValues
y_values = Charts(c).SeriesCollection(s).Values
'Charts(c).SeriesCollection(s).XValues = "='Calc'!$C$" & start_cell & ":$C$" & end_cell
'Charts(c).SeriesCollection(s).Values = "='Calc'!$E$" & start_cell & ":$E$" & end_cell
Next s
Next c
End Sub
As you can see I've tried two things, first I tried to change the string of the source data, however this meant that every series would have C and E as their source data. So I wanted to retrieve the x and y values in string format. This does not work yet, it returns an array with the values of all the entries in the series source data. From that array I can not retrieve the column where the data came from.
Help much appreciated