PC Review


Reply
Thread Tools Rate Thread

Colors on a pie chart

 
 
ML
Guest
Posts: n/a
 
      10th Sep 2008
Hi guys,

I am trying to create a macro to re-colour a selection of pie charts with
standard colours. They all have a different number of points but I want the
same colour sequence for each chart.
For example:
ActiveChart.SeriesCollection(1).Points(1).Interior.ColorIndex = 55
ActiveChart.SeriesCollection(1).Points(2).Interior.ColorIndex = 47 etc...
However, I don't know how to do it for the variable number of points.

Any suggestions?

Thanks.

 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      10th Sep 2008
Sub PrettyPie()
Dim n As Long
Dim arr
Dim cht As Chart
Dim sr As Series
Dim pt As Point

' fill this array with at least as many colorindex's
' as any potential qty of points

arr = Array(55, 47, 11, 5, 49, 14, 51, 10, _
52, 12)

' ensure a chart is active
Set cht = ActiveChart
If cht Is Nothing Then
MsgBox "Select a pie chart to colour"
Exit Sub
End If

Set sr = cht.SeriesCollection(1)

For Each pt In sr.Points
pt.Interior.ColorIndex = arr(n)
If n = UBound(arr) Then
n = 0
Else
n = n + 1
End If
Next

End Sub

Consider also customizing the chart colours in the bottom two rows of the
extended palette, these are the default or automatic colours that are
applied.

Regards,
Peter T

"ML" <(E-Mail Removed)> wrote in message
news:41AFF236-6D5B-47B2-BFEC-(E-Mail Removed)...
> Hi guys,
>
> I am trying to create a macro to re-colour a selection of pie charts with
> standard colours. They all have a different number of points but I want
> the
> same colour sequence for each chart.
> For example:
> ActiveChart.SeriesCollection(1).Points(1).Interior.ColorIndex = 55
> ActiveChart.SeriesCollection(1).Points(2).Interior.ColorIndex = 47 etc...
> However, I don't know how to do it for the variable number of points.
>
> Any suggestions?
>
> Thanks.
>



 
Reply With Quote
 
ML
Guest
Posts: n/a
 
      10th Sep 2008
Hi

Thanks for this. It's worked well.

My pie is now pretty.

ML

"Peter T" wrote:

> Sub PrettyPie()
> Dim n As Long
> Dim arr
> Dim cht As Chart
> Dim sr As Series
> Dim pt As Point
>
> ' fill this array with at least as many colorindex's
> ' as any potential qty of points
>
> arr = Array(55, 47, 11, 5, 49, 14, 51, 10, _
> 52, 12)
>
> ' ensure a chart is active
> Set cht = ActiveChart
> If cht Is Nothing Then
> MsgBox "Select a pie chart to colour"
> Exit Sub
> End If
>
> Set sr = cht.SeriesCollection(1)
>
> For Each pt In sr.Points
> pt.Interior.ColorIndex = arr(n)
> If n = UBound(arr) Then
> n = 0
> Else
> n = n + 1
> End If
> Next
>
> End Sub
>
> Consider also customizing the chart colours in the bottom two rows of the
> extended palette, these are the default or automatic colours that are
> applied.
>
> Regards,
> Peter T
>
> "ML" <(E-Mail Removed)> wrote in message
> news:41AFF236-6D5B-47B2-BFEC-(E-Mail Removed)...
> > Hi guys,
> >
> > I am trying to create a macro to re-colour a selection of pie charts with
> > standard colours. They all have a different number of points but I want
> > the
> > same colour sequence for each chart.
> > For example:
> > ActiveChart.SeriesCollection(1).Points(1).Interior.ColorIndex = 55
> > ActiveChart.SeriesCollection(1).Points(2).Interior.ColorIndex = 47 etc...
> > However, I don't know how to do it for the variable number of points.
> >
> > Any suggestions?
> >
> > Thanks.
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart Colors awach Microsoft Access Reports 0 15th Apr 2009 08:12 PM
Bar Chart colors less than zero ORLANDO VAZQUEZ Microsoft Excel Misc 2 28th Jan 2009 09:25 PM
Pie Chart Colors Question Boy Microsoft Excel Programming 1 17th Apr 2008 11:42 AM
pie chart colors deb Microsoft Access Forms 0 17th Mar 2008 12:47 PM
static colors in chart chart =?Utf-8?B?Sm9oYW4=?= Microsoft Excel Charting 1 22nd Sep 2005 01:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:25 PM.