Question : How to copy line chart color and apply on on the chart title (Excel 2007/VBA)

Hello experts,

I have a group of line charts embedded in one Excel sheet, and each line has a different color.
Using VBA code, I need to loop through each chart, copy the color of the line chart and apply it on the chart title.

Could someone please suggest the VBA code for the above.

Thank you

 
Attachments:
 
Charts before running the macro
Charts before running the macro
 
 
Charts after running the macro
Charts after running the macro
 

Answer : How to copy line chart color and apply on on the chart title (Excel 2007/VBA)

It worked when I tested.

Sub ChartManip()
Dim mb As Workbook
Dim ms As Worksheet
Dim mCh As ChartObject


Set mb = ThisWorkbook
Set ms = mb.Worksheets("Sheet1")
For Each mCh In ms.ChartObjects
    mCh.Chart.ChartTitle.Font.ColorIndex = mCh.Chart.SeriesCollection(1).Border.ColorIndex

Next mCh
End Sub
Random Solutions  
 
programming4us programming4us