Question on formatting a single point in a chart with VBA

TomCon

Active Member
Joined
Mar 31, 2011
Messages
373
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
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!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
THIS THREAD IS RETRACTED! No need to reply. I have figured out the reason for this. It is too long and obscure to explain. Sorry for the bother. Don't know if there is a way to delete the thread, so posting this response.

Tom
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,799
Members
449,095
Latest member
m_smith_solihull

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