PC Review


Reply
Thread Tools Rate Thread

changing colours on chart series

 
 
JillC
Guest
Posts: n/a
 
      25th Sep 2008
I am using macros to create 4 charts from the data on one spreadsheet, each
chart (consisting of 2 series) has different colours. Using the coding below
will change the colours after running the macro. When the macro finishes,
Series 2 on each chart is selected. When I click away from the chart the
colour reverts back to the original default colours. Annoyingly it sometimes
does not happen to all four charts, but 3 out of the 4 will be wrong.
I know there is a glitch with pivot table charts, and although the data
originally came from a pivot table, the data I am using has been copied and
pasted as values. Do I need to use the pivot table solution to get my coding
to work properly or is there something wrong with the coding?

Sub ColourReset()
' reset colours of charts
mySheet1 = "Chart1"
myColour1 = 46
myColour2 = 40
ColourCharts
mySheet1 = "Chart2"
myColour1 = 10
myColour2 = 35
ColourCharts
mySheet1 = "Chart3"
myColour1 = 54
myColour2 = 39
ColourCharts
mySheet1 = "Chart4"
myColour1 = 11
myColour2 = 37
ColourCharts

End Sub

Sub ColourCharts()

'
Sheets(mySheet1).Activate
ActiveSheet.ChartObjects(1).Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = myColour1
.Pattern = xlSolid
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = myColour2
.Pattern = xlSolid
End With
End Sub

--
Thanks, Jill
 
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
Changing cell colours on a pie chart acprc Microsoft Excel Worksheet Functions 0 5th May 2010 11:00 AM
Colours of data series in pie chart vanish in slide show Andy Microsoft Powerpoint 3 15th May 2009 03:21 PM
Changing chart colours using VBA =?Utf-8?B?VG9tbW9VSw==?= Microsoft Excel Programming 2 8th Feb 2006 06:59 PM
changing colours on stacked bar chart sphenisc Microsoft Excel Programming 1 10th Jun 2004 03:32 AM
Changing pie chart colours Chris Hind Microsoft Powerpoint 1 9th Aug 2003 03:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:17 PM.