Red over White
Board Regular
- Joined
- Jul 16, 2011
- Messages
- 129
- Office Version
- 365
- Platform
- MacOS
I have a line graph that can have a variable number (currently 31) of lines in it, some of which will be same colour. The macro currently reads:
Sub InterestG1()
Sheets("InterestG").Activate
With ActiveChart
' 1 - 5
.SeriesCollection(1).Format.Line.ForeColor.RGB = RGB(192, 192, 192) ' 25% Grey - B25
.SeriesCollection(2).Format.Line.ForeColor.RGB = RGB(255, 0, 255) ' Magenta - C25
.SeriesCollection(3).Format.Line.ForeColor.RGB = RGB(210, 180, 140) ' Tan - D25 and so on
.SeriesCollection(4).Format.Line.ForeColor.RGB = RGB(255, 255, 0) ' Yellow
.SeriesCollection(5).Format.Line.ForeColor.RGB = RGB(51, 102, 155) ' Aqua
' 6 - 10
.SeriesCollection(6).Format.Line.ForeColor.RGB = RGB(144, 238, 144) ' Light Green
.SeriesCollection(7).Format.Line.ForeColor.RGB = RGB(144, 238, 144) ' Light Green
.SeriesCollection(8).Format.Line.ForeColor.RGB = RGB(0, 128, 128) ' Teal
.SeriesCollection(9).Format.Line.ForeColor.RGB = RGB(51, 102, 155) ' Aqua
.SeriesCollection(10).Format.Line.ForeColor.RGB = RGB(0, 65, 194) ' Blueberry
' 11- 15
.SeriesCollection(11).Format.Line.ForeColor.RGB = RGB(153, 204, 155) ' Aluminium
.SeriesCollection(12).Format.Line.ForeColor.RGB = RGB(51, 102, 155) ' Aqua
.SeriesCollection(13).Format.Line.ForeColor.RGB = RGB(153, 204, 155) ' Aluminium
.SeriesCollection(14).Format.Line.ForeColor.RGB = RGB(128, 0, 64) ' Maroon
.SeriesCollection(15).Format.Line.ForeColor.RGB = RGB(102, 204, 255) ' Sky
' 16 - 20
.SeriesCollection(16).Format.Line.ForeColor.RGB = RGB(102, 204, 255) ' Sky
.SeriesCollection(17).Format.Line.ForeColor.RGB = RGB(255, 111, 207) ' Carnation
.SeriesCollection(18).Format.Line.ForeColor.RGB = RGB(255, 67, 164) ' Strawberry
.SeriesCollection(19).Format.Line.ForeColor.RGB = RGB(0, 128, 0) ' Spring
.SeriesCollection(20).Format.Line.ForeColor.RGB = RGB(242, 133, 0) ' Tangerine
' 21 - 25
.SeriesCollection(21).Format.Line.ForeColor.RGB = RGB(255, 0, 255) ' Magenta
.SeriesCollection(22).Format.Line.ForeColor.RGB = RGB(242, 133, 0) ' Tangerine
.SeriesCollection(23).Format.Line.ForeColor.RGB = RGB(210, 180, 140) ' Tan
.SeriesCollection(24).Format.Line.ForeColor.RGB = RGB(242, 133, 0) ' Tangerine
.SeriesCollection(25).Format.Line.ForeColor.RGB = RGB(128, 64, 0) ' Mocha
' The rest
.SeriesCollection(26).Format.Line.ForeColor.RGB = RGB(128, 0, 64) ' Maroon
.SeriesCollection(27).Format.Line.ForeColor.RGB = RGB(0, 65, 194) ' Blueberry
.SeriesCollection(28).Format.Line.ForeColor.RGB = RGB(255, 0, 0) ' Red
.SeriesCollection(29).Format.Line.ForeColor.RGB = RGB(153, 204, 155) ' Aluminium
.SeriesCollection(30).Format.Line.ForeColor.RGB = RGB(255, 165, 0) ' Orange
.SeriesCollection(31).Format.Line.ForeColor.RGB = RGB(192, 192, 192) ' 25% Grey
End With
End Sub
The notations at the end of the first three SeriesCollection refer to cells that have the RGB colour information in them, and all corresponding 31 cell entries are the product of a formula.
Before I can start to look at the variable aspect, is there a way that I can write the macro below so it actually picks up the colour indicated from the cell and show it in the graph. All I am getting at the moment is different run time or syntax messages depending on what I have after the ‘=’ sign.
Thanks
Sub InterestG1()
Sheets("InterestG").Activate
With ActiveChart
' 1 - 5
.SeriesCollection(1).Format.Line.ForeColor.RGB = RGB(192, 192, 192) ' 25% Grey - B25
.SeriesCollection(2).Format.Line.ForeColor.RGB = RGB(255, 0, 255) ' Magenta - C25
.SeriesCollection(3).Format.Line.ForeColor.RGB = RGB(210, 180, 140) ' Tan - D25 and so on
.SeriesCollection(4).Format.Line.ForeColor.RGB = RGB(255, 255, 0) ' Yellow
.SeriesCollection(5).Format.Line.ForeColor.RGB = RGB(51, 102, 155) ' Aqua
' 6 - 10
.SeriesCollection(6).Format.Line.ForeColor.RGB = RGB(144, 238, 144) ' Light Green
.SeriesCollection(7).Format.Line.ForeColor.RGB = RGB(144, 238, 144) ' Light Green
.SeriesCollection(8).Format.Line.ForeColor.RGB = RGB(0, 128, 128) ' Teal
.SeriesCollection(9).Format.Line.ForeColor.RGB = RGB(51, 102, 155) ' Aqua
.SeriesCollection(10).Format.Line.ForeColor.RGB = RGB(0, 65, 194) ' Blueberry
' 11- 15
.SeriesCollection(11).Format.Line.ForeColor.RGB = RGB(153, 204, 155) ' Aluminium
.SeriesCollection(12).Format.Line.ForeColor.RGB = RGB(51, 102, 155) ' Aqua
.SeriesCollection(13).Format.Line.ForeColor.RGB = RGB(153, 204, 155) ' Aluminium
.SeriesCollection(14).Format.Line.ForeColor.RGB = RGB(128, 0, 64) ' Maroon
.SeriesCollection(15).Format.Line.ForeColor.RGB = RGB(102, 204, 255) ' Sky
' 16 - 20
.SeriesCollection(16).Format.Line.ForeColor.RGB = RGB(102, 204, 255) ' Sky
.SeriesCollection(17).Format.Line.ForeColor.RGB = RGB(255, 111, 207) ' Carnation
.SeriesCollection(18).Format.Line.ForeColor.RGB = RGB(255, 67, 164) ' Strawberry
.SeriesCollection(19).Format.Line.ForeColor.RGB = RGB(0, 128, 0) ' Spring
.SeriesCollection(20).Format.Line.ForeColor.RGB = RGB(242, 133, 0) ' Tangerine
' 21 - 25
.SeriesCollection(21).Format.Line.ForeColor.RGB = RGB(255, 0, 255) ' Magenta
.SeriesCollection(22).Format.Line.ForeColor.RGB = RGB(242, 133, 0) ' Tangerine
.SeriesCollection(23).Format.Line.ForeColor.RGB = RGB(210, 180, 140) ' Tan
.SeriesCollection(24).Format.Line.ForeColor.RGB = RGB(242, 133, 0) ' Tangerine
.SeriesCollection(25).Format.Line.ForeColor.RGB = RGB(128, 64, 0) ' Mocha
' The rest
.SeriesCollection(26).Format.Line.ForeColor.RGB = RGB(128, 0, 64) ' Maroon
.SeriesCollection(27).Format.Line.ForeColor.RGB = RGB(0, 65, 194) ' Blueberry
.SeriesCollection(28).Format.Line.ForeColor.RGB = RGB(255, 0, 0) ' Red
.SeriesCollection(29).Format.Line.ForeColor.RGB = RGB(153, 204, 155) ' Aluminium
.SeriesCollection(30).Format.Line.ForeColor.RGB = RGB(255, 165, 0) ' Orange
.SeriesCollection(31).Format.Line.ForeColor.RGB = RGB(192, 192, 192) ' 25% Grey
End With
End Sub
The notations at the end of the first three SeriesCollection refer to cells that have the RGB colour information in them, and all corresponding 31 cell entries are the product of a formula.
Before I can start to look at the variable aspect, is there a way that I can write the macro below so it actually picks up the colour indicated from the cell and show it in the graph. All I am getting at the moment is different run time or syntax messages depending on what I have after the ‘=’ sign.
Thanks