ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Charts and Charting in Excel (https://www.excelbanter.com/charts-charting-excel/)
-   -   Update line chart series colors (https://www.excelbanter.com/charts-charting-excel/266421-update-line-chart-series-colors.html)

Apple Ling

Update line chart series colors
 
Hi,

I have a combination bar and line chart. I need to update the chart color based on the color stored at sheet1. However, i just manage to update the bar color but the macro seem not working for the line.

Here is the code

Sub UpdateColours()

Dim MyArray As Range 'The Worksheet with colour selections
Dim MyColour As Object 'object in range
Dim iSeries As Long
Dim rSeries As Range


'YOU MUST CUSTOMISE THIS NEXT SECTION: CHECK THE CH AND TBL SHEET NAMES

Set MyArray = Sheets("Sheet1").Range("L2:L20")

Application.ScreenUpdating = False

With ActiveChart

Do While k < .SeriesCollection.Count
k = k + 1

For Each MyColour In MyArray
If .SeriesCollection(k).Name = "VOL - " & MyColour Then

.SeriesCollection(k).Interior.Color = MyColour.Interior.Color

ElseIf .SeriesCollection(k).Name = "AVG - " & MyColor Then
.SeriesCollection(k).Interior.Color = MyColour.Interior.Color


End If
Next
Loop
End With


Application.ScreenUpdating = True

End Sub


All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com