LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Setting the Colour of Individual Items within a Legend

I am using the following Code to plot the chart, but Im not sure how to getit
to let me decide the colours of the Columns it displays

Sub Chrt_Incident_Age_Click()

Dim chtChart As Chart

' Remove Existing Chart

ActiveSheet.ChartObjects.Delete

' Create a new chart.

Set chtChart = Charts.Add
Set chtChart = chtChart.Location(Whe=xlLocationAsObject,
Name:="CHARTS")

With chtChart

.ChartType = xlCylinderCol

' Set data source range.

.SetSourceData Source:=Sheets("BASIC CHART DATA").Range("L11:X14"),
PlotBy:=xlRows
.HasTitle = True
.ChartTitle.Text = "Current Status"
.SeriesCollection(1).XValues = "='BASIC CHART DATA'!$M$4:$X$10"

'.SeriesCollection(1).XValues = "='BASIC CHART DATA'!$M$4:$X$10"

' The Parent property is used to set properties of the Chart.

With .Parent
.Top = Range("G3").Top
.Left = Range("G3").Left
.Width = Range("G3:R30").Width
.Height = Range("G3:R30").Height


End With

End With

ActiveChart.Legend.Select
Selection.Delete

End Sub

I tried the following code that was mentioned on here and it doesnot appear
to do anything. DOes anyone have any ideas?

For i = 1 To ActiveChart.Legend.LegendEntries.Count
ActiveChart.Legend.LegendEntries(i).LegendKey.Sele ct

With Selection.Interior
Select Case i
Case 1
.Color = RGB(0, 51, 153)
Case 2
.Color = RGB(64, 102, 178)
Case 3
.Color = RGB(128, 153, 204)
Case 4
.Color = RGB(102, 102, 255)
Case 5
.Color = RGB(140, 140, 255)
Case 6
.Color = RGB(178, 178, 255)
Case 7
end select
Next

I hope this will help you!!!

Best regards,
Shiva

"Michael Hudston" wrote:

As a reference this is the current VBA that I am using to display the chart.

Sub Cause_During_Corr_Acc_Click()

Dim chtChart As Chart

'Remove Existing Chart

ActiveSheet.ChartObjects.Delete

'Create a new chart.

Set chtChart = Charts.Add
Set chtChart = chtChart.Location(Whe=xlLocationAsObject, Name:="CHART")

With chtChart

.ChartType = xlColumnClustered

'Set data source range.

.SetSourceData Source:=Sheets("BASIC CHART DATA").Range("B17:C28"),
PlotBy:=xlRows
.HasTitle = True
.ChartTitle.Text = "Cause Defined During Corrective Action"
.Axes(xlCategory).Delete

'The Parent property is used to set properties of
'the Chart.

With .Parent
.Top = Range("D2").Top
.Left = Range("D2").Left
.Name = "chart_CDCA"
End With

End With

End Sub

"Michael Hudston" wrote:

I am creating all my charts in VBA, so they appear at a touch of a button. I
am looking to set the following properties, and cant seem to find them in the
help.

The Colours of the Columns in my Graph, so particular colums are always RED,
YELLOW, GREEN, etc.

The font size of the Chart Title and Legend.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Undelete Legend Items Sloth Charts and Charting in Excel 3 April 3rd 23 10:54 AM
Change order of items in a legend bmac Charts and Charting in Excel 1 March 11th 10 04:43 PM
Chart Legend Items: hide/show Richard Ahlvin Charts and Charting in Excel 5 September 5th 05 03:04 PM
Order of items in legend Darryl Charts and Charting in Excel 3 July 20th 05 03:40 PM
XY Scatter Legend when Edit Individual Markers John Charts and Charting in Excel 6 June 13th 05 03:06 PM


All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"