Color Chart Series Utility
Download the attached Excel file to see the code behind it and how this utility works. Its makes colouring of chart series easier in a very user-friendly way.
Sub SetChartSeriesColor(cht As ChartObject, rngColor As Range) Dim srs As Series Dim lngColor Dim strNotFound As String For Each srs In cht.Chart.SeriesCollection On Error Resume Next lngColor = rngColor.Find(srs.Name, , xlValues, xlWhole).Interior.Color If Err.Number = 0 Then If Application.Version < 12 Then srs.Interior.Color = lngColor Else srs.Format.Fill.ForeColor.RGB = lngColor End If Else If Len(strNotFound) = 0 Then strNotFound = srs.Name Else strNotFound = strNotFound & vbCrLf & srs.Name End If End If On Error GoTo 0 Next srs If Len(strNotFound) <> 0 Then MsgBox "Colors not found for these series:" & vbCrLf & strNotFound End If Set srs = Nothing End Sub
Attachment | Size |
---|---|
ColorChartSeries.xls | 43 KB |
»
- Vishesh's blog
- Login or register to post comments
- 7464 reads
Thanks
Besides others, thats a real good one too. Very useful to make a project user-friendly. More of your blog are welcome. Multi-level sort...the other blog is really cool. So many people in my office follow you blogs on excelexperts.com.