Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / April 2008

Tip: Looking for answers? Try searching our database.

Pie Chart Colors

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Question Boy - 17 Apr 2008 03:14 GMT
I have a simple table with three columns

1. Title
2. Value
3. Color

With data like
B 8 Blue
J 5 Yellow
V 12 Green

How can I using vba set the color for each pie chart segment based on the
specified color from the respective data from the color column.  So the slice
representing B (8) would be blue and the J (5) would be yellow, etc.

Thank you

QB
Peter T - 17 Apr 2008 11:42 GMT
Format your "color" cells with colours from the drop-down Fill color
palette. In the following change rngFirstClrCell = to suit

Sub test()
Dim n As Long
Dim cht As Chart
Dim pt As Point
Dim rFirstClrCell As Range

   Set rFirstClrCell = Range("C3")    ' << CHANGE

   Set cht = ActiveChart
   If cht Is Nothing Then
       MsgBox "Select a chart"
       Exit Sub
   End If

   For Each pt In cht.SeriesCollection(1).Points
       pt.Fill.ForeColor.SchemeColor = _
                       rFirstClrCell.Offset(n, 0).Interior.ColorIndex
       n = n + 1
   Next

End Sub

Regards,
Peter T

> I have a simple table with three columns
>
[quoted text clipped - 14 lines]
>
> QB
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.