Thx Peter, it works perfectly !
Though not quite it seems!
Just if you could add some code:
Are you series and Legend formats not using default formats. If so creat a
default chart, then record a macro while changing all the formats as
required. This will give you the syntax of how to check properties before
changing them (though you won't need any of the Select stuff that gets
recorded.
Having got the properties you will need to store them. There are vaious
ways, either with Static variables or at module level. If you are dealing
with several charts it might be easier to create arrays or a collection of
properties for each chart.
In my quick test nothing moved in my chart after resetting the Legend's
position. But charts can have a habit of doing that, if so means storing
position coordinates of chartarea, plotarea, titles, legend, possibly even
axis scale properties. This could all get quite involved.
A different approach might be to temporarily defne your chart as a custom
type. After changing reapply the Custom type then delete it. Again you can
get all the code by recording a macro.
* arguments passed to the routine:
In the example change
Sub Test()
to
Sub Test(cht As Chart, sr As Series, bVis As Boolean)
delete cht, sr & bVis after all the Dim's
delete
nSrIdx = 3 ' < change to suit
bVis = Not bVis
Set cht = ActiveChart
Change
With cht.SeriesCollection(nSrIdx)
to
With sr
(I've probably missed something similar things to delete/change)
In the calling routine something like
Sub ToggleSeries()
Dim cht as Chart, sr as Series
Dim bVis ' if you will want to check existing state of Series before doing
anything
or
Static bVis ' to retain previous setting
set cht = whatever chart
set sr = cht.seriesCollection("mySeries") , or by index number
Call Test(,cht,sr,bVis)
Regards,
Peter T