I have an X-Y scatterchart with 6 series. Currently the series is 943 points, and every day the range gets one row added so it goes up to 944 points, 945... . I have a macro that does that, loops through the series' and changes the range for each one.
All of the series have "none" for Marker and show lines only.
In the UI, i selected one of the series, and then selected its last point, and "edited" that point, and i selected a Marker type for that point. I did that for two series. Daily, when i run my macro that extends the series by one row, the two series for which i have done this have a different behavior. In one of the cases, the Marker format sticks to a specific point, so today its on the last point, tomorrow it will be on the second to last, etc. But, for the other series, it sticks to the idea of "last" point, and every day it is on the last point of that series (which is the behavior i desire).
So, i recorded a macro when formatting the Marker of the last point for both series. What i found is very surprising and perplexing to me. In one series, the recorded VBA formats points(944) (the last point). But, in the other series (the one where the formatting sticks, the behavior i want), it records formatting Points(1). But, to format points(1), it would seem to me that for that series, it is considering the points array as if it were reversed. I'll show the recorded macros now.
If anybody can explain why the two series' record the formatting of the last point differently, i would like to understand it. And, as a question of what i want to accomplish, "How can I make both series have the behavior of always having formatting stick to the the last point when i update the range daily?
For one of the series, this is the macro recorded by selecting the last point and formatting it. After the range is later extended, in this case the "last" point does not remain formatted, but the particular point (in this case 944) remains formatted.
'
' Macro2 Macro
'
'
ActiveChart.FullSeriesCollection(6).Select
ActiveChart.FullSeriesCollection(6).Points(944).Select
With Selection
.MarkerStyle = -4142
.MarkerSize = 8
End With
Selection.MarkerStyle = 2
Selection.MarkerSize = 7
End Sub
In this case i record a macro, again selecting "the last" point of the series and formatting it. But, in this case the macro records formatting "points(1)", and in this case, after each daily update is done, the formatting sticks to the "last" point of the series.
Sub Macro3()
'
' Macro3 Macro
'
'
ActiveChart.FullSeriesCollection(5).Select
ActiveChart.FullSeriesCollection(5).Points(1).Select
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
.Solid
End With
End Sub
This is the inner loop that does the work of extending the range for each series by one row, which is run daily. I changed the font color on the line that re-sets the series range.
For i = 1 + SerSkip To ser_ct + SerSkip
serfmla = ActiveChart.SeriesCollection(i).Formula
fmlasplit() = Split(serfmla, ",")
newx = Left(fmlasplit(1), Len(fmlasplit(1)) - newlenck) & newrw
newy = Left(fmlasplit(2), Len(fmlasplit(2)) - newlenck) & newrw
newfmla = fmlasplit(0) & "," & newx & "," & newy & "," & fmlasplit(3)
With Sheets(shtnam)
.Protect DrawingObjects:=True, Contents:=False
ActiveChart.SeriesCollection(i).Formula = newfmla
.Activate 'optional
.Unprotect
End With
Next i
Any help appreciated!
Thanks!
All of the series have "none" for Marker and show lines only.
In the UI, i selected one of the series, and then selected its last point, and "edited" that point, and i selected a Marker type for that point. I did that for two series. Daily, when i run my macro that extends the series by one row, the two series for which i have done this have a different behavior. In one of the cases, the Marker format sticks to a specific point, so today its on the last point, tomorrow it will be on the second to last, etc. But, for the other series, it sticks to the idea of "last" point, and every day it is on the last point of that series (which is the behavior i desire).
So, i recorded a macro when formatting the Marker of the last point for both series. What i found is very surprising and perplexing to me. In one series, the recorded VBA formats points(944) (the last point). But, in the other series (the one where the formatting sticks, the behavior i want), it records formatting Points(1). But, to format points(1), it would seem to me that for that series, it is considering the points array as if it were reversed. I'll show the recorded macros now.
If anybody can explain why the two series' record the formatting of the last point differently, i would like to understand it. And, as a question of what i want to accomplish, "How can I make both series have the behavior of always having formatting stick to the the last point when i update the range daily?
For one of the series, this is the macro recorded by selecting the last point and formatting it. After the range is later extended, in this case the "last" point does not remain formatted, but the particular point (in this case 944) remains formatted.
'
' Macro2 Macro
'
'
ActiveChart.FullSeriesCollection(6).Select
ActiveChart.FullSeriesCollection(6).Points(944).Select
With Selection
.MarkerStyle = -4142
.MarkerSize = 8
End With
Selection.MarkerStyle = 2
Selection.MarkerSize = 7
End Sub
In this case i record a macro, again selecting "the last" point of the series and formatting it. But, in this case the macro records formatting "points(1)", and in this case, after each daily update is done, the formatting sticks to the "last" point of the series.
Sub Macro3()
'
' Macro3 Macro
'
'
ActiveChart.FullSeriesCollection(5).Select
ActiveChart.FullSeriesCollection(5).Points(1).Select
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent2
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
.Solid
End With
End Sub
This is the inner loop that does the work of extending the range for each series by one row, which is run daily. I changed the font color on the line that re-sets the series range.
For i = 1 + SerSkip To ser_ct + SerSkip
serfmla = ActiveChart.SeriesCollection(i).Formula
fmlasplit() = Split(serfmla, ",")
newx = Left(fmlasplit(1), Len(fmlasplit(1)) - newlenck) & newrw
newy = Left(fmlasplit(2), Len(fmlasplit(2)) - newlenck) & newrw
newfmla = fmlasplit(0) & "," & newx & "," & newy & "," & fmlasplit(3)
With Sheets(shtnam)
.Protect DrawingObjects:=True, Contents:=False
ActiveChart.SeriesCollection(i).Formula = newfmla
.Activate 'optional
.Unprotect
End With
Next i
Any help appreciated!
Thanks!