I have a pivot chart and I'm trying to format certain dataseries in my chart with a pattern. I recorded a macro to see how Excel would do that. This gave me:
With Selection.Format.Fill
.Visible = msoTrue
.Patterned msopatternDarkUpwardDiagonal
End With
Which I've adapted to:
With chrt1Overview 'chart object codename
(....)
With .FullSeriesCollection(i) 'iterating through series
.ChartType = xlColumnStacked
If .Name Like "FORECAST" Then
With .Format.Fill
.Visible = msoTrue
.Patterned msoPatternDarkUpwardDiagonal
End With
End If
End with
End with
This gives me the error below and highlights both msoTrue
and msoPatternDarkupwardDiagonal
in my code
Compile error:
Variable not defined
Running the macro as created by the recorder does not work either, the mso
"variables" are empty and gives an error that the specified value is out of range but does not give me a compile error because the Option Explicit
is not set on this module.
What is the correct way to set a pattern fill on a data series?