Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Set color for chart serie in excel 2007/2010

Hi!
I want to do a macro that sets the color for the chart series to the color
the company has desided to use. We have a theme but we can only set color for
the first 6 series and we often use much more series.
I have understod that this isnt so easy as to loop thru the series and set
the color since the color is set on different ways depending on the charttype
for the serie, or is it a way to do this so it works for all chart types?

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Set color for chart serie in excel 2007/2010

As you say only six basic colours are available. However each subsequent set
of six is a shade lighter, although each incremental difference in shade is
not very noticeable from the previous set.

One approach is to define at least as many colours in RGB format as you'll
need, then a simple macro can apply them in order to your series. Post back
if not sure how to go about that, and say how many colours you'll need.

Regards,
Peter T


"Lina" wrote in message
...
Hi!
I want to do a macro that sets the color for the chart series to the color
the company has desided to use. We have a theme but we can only set color
for
the first 6 series and we often use much more series.
I have understod that this isnt so easy as to loop thru the series and set
the color since the color is set on different ways depending on the
charttype
for the serie, or is it a way to do this so it works for all chart types?

thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Set color for chart serie in excel 2007/2010

Hi,
Thank you for your answer and maybe you can help me a bit further. I have to
rewrite some code that was written for excel xp and that doesnt work so god
(for many different reasons) The old code uses customcharts
(xxx.Chart.ApplyCustomType ChartType:=xlUserDefined, TypeName:="test") but I
understand that it's better to use the new chartstyles (is it?) since the
customcharts not will be supported further on (is this right?)

I would like to make a button that loops all series in the selected chart
and changes the color. My problem is that I must handle each diagram type of
serie and Im not sure how to do this the best way so that I cover as many
charttypes as possible without having runtime error.

thanks

"Peter T" wrote:

As you say only six basic colours are available. However each subsequent set
of six is a shade lighter, although each incremental difference in shade is
not very noticeable from the previous set.

One approach is to define at least as many colours in RGB format as you'll
need, then a simple macro can apply them in order to your series. Post back
if not sure how to go about that, and say how many colours you'll need.

Regards,
Peter T


"Lina" wrote in message
...
Hi!
I want to do a macro that sets the color for the chart series to the color
the company has desided to use. We have a theme but we can only set color
for
the first 6 series and we often use much more series.
I have understod that this isnt so easy as to loop thru the series and set
the color since the color is set on different ways depending on the
charttype
for the serie, or is it a way to do this so it works for all chart types?

thanks



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Set color for chart serie in excel 2007/2010

In Excel 2007 customs charts are saved as chart templates. Manually look at
Change ChartType, Templates. In VBA help look at AddChartAutoFormat and
ApplyChartTemplate

Your other question is very vague, try and explain with some detail. Eg, do
you have a set of colours, what ChartType are your series, eg bar or line.
and looking to change fill/interior or border/line.

Regards,
Peter T


"Lina" wrote in message
...
Hi,
Thank you for your answer and maybe you can help me a bit further. I have
to
rewrite some code that was written for excel xp and that doesnt work so
god
(for many different reasons) The old code uses customcharts
(xxx.Chart.ApplyCustomType ChartType:=xlUserDefined, TypeName:="test") but
I
understand that it's better to use the new chartstyles (is it?) since the
customcharts not will be supported further on (is this right?)

I would like to make a button that loops all series in the selected chart
and changes the color. My problem is that I must handle each diagram type
of
serie and Im not sure how to do this the best way so that I cover as many
charttypes as possible without having runtime error.

thanks

"Peter T" wrote:

As you say only six basic colours are available. However each subsequent
set
of six is a shade lighter, although each incremental difference in shade
is
not very noticeable from the previous set.

One approach is to define at least as many colours in RGB format as
you'll
need, then a simple macro can apply them in order to your series. Post
back
if not sure how to go about that, and say how many colours you'll need.

Regards,
Peter T


"Lina" wrote in message
...
Hi!
I want to do a macro that sets the color for the chart series to the
color
the company has desided to use. We have a theme but we can only set
color
for
the first 6 series and we often use much more series.
I have understod that this isnt so easy as to loop thru the series and
set
the color since the color is set on different ways depending on the
charttype
for the serie, or is it a way to do this so it works for all chart
types?

thanks



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Set color for chart serie in excel 2007/2010

The company has a set of color and they dont allow any other colors. I
have done some chart templates with the predifined colors. The problem
is that if a user adds more data to a chart that is allready done the
new serie will not use the color that is saved in the chart template,
it uses the built in colors instead. Do get the right colors you can
apply the chart template again but, if the user has made som settings
for the chart thoose will be overriden by the template. So instead I
would like to have a button "set company color" and that button should
go thru the series and set the color that is allowed by the company. I
would like it to work for all type of charts. I have it working for
bar, line and pie but what if the user has made a bar and a line, is
there a way to get this to work for all chart types or must I treat
each type of serie differently?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Set color for chart serie in excel 2007/2010

I'm not sure I quite follow. Indeed the code is slightly different to apply
colour to Line or Fill but you say you have already got the code to do that.
The code is also slightly different in 2007+ and earlier versions.

For earlier versions have you considered making a workbook template for all
users with a customized palette. In particular customize the 6th row for
fill colours and the 7th row of 8 for line colours. If you do that all
charts will be automatically applied with your default colours (at least for
the first 8 series).

That approach is not useful in 2007. You can of course apply your own Office
theme. Colours are the same for fills and lines (unlike earlier versions).
Each set of series uses a different shade of them colour.

Another way is to defile your own palette, one way - (this assumes 2007)

- Colour format some cells, at least as many as there will ever be series in
a chart, Ctrl-F1, Fill, More colors..
- Name the coloured cells say "Swatch"

In your code that colours the series start with this

Dim pal() as long
getColors pal

and add this function

Sub getColors(pal() As Long)
Dim i As Long
Dim rng As Range, c As Range
Set rng = ActiveWorkbook.Names("Swatch").RefersToRange
ReDim pal(1 To rng.Count)
For Each c In rng
i = i + 1
pal(i) = c.Interior.Color
Next
End Sub


Do you know know to process each chart on each sheet?

Regards,
Peter T



"Lina" wrote in message
...
The company has a set of color and they dont allow any other colors. I
have done some chart templates with the predifined colors. The problem
is that if a user adds more data to a chart that is allready done the
new serie will not use the color that is saved in the chart template,
it uses the built in colors instead. Do get the right colors you can
apply the chart template again but, if the user has made som settings
for the chart thoose will be overriden by the template. So instead I
would like to have a button "set company color" and that button should
go thru the series and set the color that is allowed by the company. I
would like it to work for all type of charts. I have it working for
bar, line and pie but what if the user has made a bar and a line, is
there a way to get this to work for all chart types or must I treat
each type of serie differently?



Reply
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
Change gradient color in chart for Excel 2007 NonTechie Charts and Charting in Excel 6 May 9th 23 03:43 AM
Chart issue--works in 2007, not in 2010 tmidgett Charts and Charting in Excel 0 February 8th 11 05:43 PM
Excel 2007 Chart - determining the color of a chart style Shane Devenshire[_2_] Charts and Charting in Excel 1 February 6th 10 04:09 AM
Saving chart templates - xl 2007 (and 2010?) Reg Charts and Charting in Excel 0 January 13th 10 03:36 PM
Excel 2007 chart gridline color using vba [email protected] Charts and Charting in Excel 2 December 17th 08 03:32 PM


All times are GMT +1. The time now is 10:57 AM.

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

About Us

"It's about Microsoft Excel"