This macro would assign a unique color to each country. For the macro t
work you have to select the chart and then execute the macro, repea
this for all the charts you have.
In the code I put
If (PTS(I) = "US") Then
.Fill.ForeColor.SchemeColor = 8
that means if US , then color scheme is 8 (blue),
If (PTS(I) = "China") Then
.Fill.ForeColor.SchemeColor = 12
that means if China, then color scheme is 12
repeat this for all other countries, I code for 4 countries.
try the below code and let me know if you have any problems
Sub Macro5()
Dim PTS As Variant
On Error GoTo A:
ActiveChart.ChartArea.Select 'selecting chart area
ActiveChart.SeriesCollection(1).Select
PTS = ActiveChart.SeriesCollection(1).XValues 'extract the values
For I = 1 To UBound(PTS) 'for every point
ActiveChart.SeriesCollection(1).Points(I).Select
With Selection 'applying the color
.Fill.Visible = True
If (PTS(I) = "US") Then
.Fill.ForeColor.SchemeColor = 8
ElseIf (PTS(I) = "India") Then
.Fill.ForeColor.SchemeColor = 35
ElseIf (PTS(I) = "China") Then
.Fill.ForeColor.SchemeColor = 12
ElseIf (PTS(I) = "UK") Then
.Fill.ForeColor.SchemeColor = 18
End If
End With
Next
A:
If Err.Description < "" Then
MsgBox "need to select chart for the macro to work"
End If
End Su
--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile:
http://www.excelforum.com/member.php...fo&userid=1627
View this thread:
http://www.excelforum.com/showthread.php?threadid=38006