N
Naz
Hi,
I want to create a little macro that automatically changes the colours of
each slice in a chart to a pre-defined colour. I can't create a pre-defined
user chart for various network reasons. So far I have the following long
winded, but easy for me to understand code, but the case select module where
the colours are selected doesn't work, i've only had a rough guess as to how
it should work, and if you can do a case select for chart slices, so i may be
well out.
Sub ChartColours()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
Slice = 1
On Error Resume Next
For x = 1 To 20 ' Im going to assume no more than 20 slices
ActiveChart.SeriesCollection(1).Points(Slice).Select
Module1.SelectionFill
Module1.SliceColour
Slice = Slice + 1
Next x
End Sub
Private Sub SelectionFill()
Selection.Fill.OneColorGradient Style:=msoGradientDiagonalUp,
Variant:=2, _
Degree:=0.231372549019608
End Sub
Private Sub SliceColour()
SelSlice = Chart.SeriesCollection(1).Points <<< I'm stuck at
this point
Select Case SelSlice
Case 1
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 1
End With
Case 2
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 2
End With
Case 3
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 3
End With
Case 4
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 4
End With
Case 5
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 5
End With
End Select
End Sub
Any help to get it working would be greatly appreciated, help to make it
work and more efficient would be even more appreciated !
regards
I want to create a little macro that automatically changes the colours of
each slice in a chart to a pre-defined colour. I can't create a pre-defined
user chart for various network reasons. So far I have the following long
winded, but easy for me to understand code, but the case select module where
the colours are selected doesn't work, i've only had a rough guess as to how
it should work, and if you can do a case select for chart slices, so i may be
well out.
Sub ChartColours()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
Slice = 1
On Error Resume Next
For x = 1 To 20 ' Im going to assume no more than 20 slices
ActiveChart.SeriesCollection(1).Points(Slice).Select
Module1.SelectionFill
Module1.SliceColour
Slice = Slice + 1
Next x
End Sub
Private Sub SelectionFill()
Selection.Fill.OneColorGradient Style:=msoGradientDiagonalUp,
Variant:=2, _
Degree:=0.231372549019608
End Sub
Private Sub SliceColour()
SelSlice = Chart.SeriesCollection(1).Points <<< I'm stuck at
this point
Select Case SelSlice
Case 1
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 1
End With
Case 2
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 2
End With
Case 3
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 3
End With
Case 4
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 4
End With
Case 5
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 5
End With
End Select
End Sub
Any help to get it working would be greatly appreciated, help to make it
work and more efficient would be even more appreciated !
regards