PC Review


Reply
Thread Tools Rate Thread

Bar chart: change color of a bar to red if value > x?

 
 
=?ISO-8859-15?Q?Christian_M=FCnscher?=
Guest
Posts: n/a
 
      31st Aug 2005
Hi, Group!

Is there a way to change the color of all or a group of bars in a bar
chart, depending on their value? E.g. if the value is below 2.5, the
color shall be green, above 2.5 the color of the whole bar should be red.

Thank you very much!

With kind regards,
Chriss
 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      31st Aug 2005
Here's an introduction to conditional charting:

http://peltiertech.com/Excel/Charts/...nalChart1.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Christian Münscher wrote:

> Hi, Group!
>
> Is there a way to change the color of all or a group of bars in a bar
> chart, depending on their value? E.g. if the value is below 2.5, the
> color shall be green, above 2.5 the color of the whole bar should be red.
>
> Thank you very much!
>
> With kind regards,
> Chriss

 
Reply With Quote
 
=?ISO-8859-15?Q?Christian_M=FCnscher?=
Guest
Posts: n/a
 
      31st Aug 2005
Hi, Jon!

Jon Peltier schrieb:
> Here's an introduction to conditional charting:
> http://peltiertech.com/Excel/Charts/...nalChart1.html


Thank you very much! Thats a great collection of tips, but thats not
what I'm looking for. I don't want do modify the tables. I thougt about
something like:

with all bars do
if cell.value < 2.5 then bar.color = green
else bar.color = red
end with

in a skript assigned to the diagrams.

The values will not be changing very often, so it doesn't need to be
fast. If that's not possible, I think I manually will paint the few bars
red that are above 2.5

regards,
Chriss
 
Reply With Quote
 
Andy Pope
Guest
Posts: n/a
 
      31st Aug 2005
Hi,

Something along these lines will colour the bars according to their
values. Under 2 is red, Over 8 is green other values left at default colour.

Sub ColorBars()
Dim intSeries As Integer
Dim intPoint As Integer
Dim vntData As Variant

With ActiveChart
For intSeries = 1 To .SeriesCollection.Count
' set bars to default
.SeriesCollection(intSeries).Interior. _
ColorIndex = xlAutomatic
vntData = .SeriesCollection(intSeries).Values
For intPoint = LBound(vntData) To UBound(vntData)
Select Case vntData(intPoint)
Case Is < 2
' red
.SeriesCollection(intSeries). _
Points(intPoint).Interior.ColorIndex = 3
Case Is > 8
' green
.SeriesCollection(intSeries). _
Points(intPoint).Interior.ColorIndex = 4
End Select
Next
Next
End With

End Sub

Cheers
Andy

Christian Münscher wrote:
> Hi, Jon!
>
> Jon Peltier schrieb:
>
>>Here's an introduction to conditional charting:
>> http://peltiertech.com/Excel/Charts/...nalChart1.html

>
>
> Thank you very much! Thats a great collection of tips, but thats not
> what I'm looking for. I don't want do modify the tables. I thougt about
> something like:
>
> with all bars do
> if cell.value < 2.5 then bar.color = green
> else bar.color = red
> end with
>
> in a skript assigned to the diagrams.
>
> The values will not be changing very often, so it doesn't need to be
> fast. If that's not possible, I think I manually will paint the few bars
> red that are above 2.5
>
> regards,
> Chriss


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
 
Reply With Quote
 
Ed Ferrero
Guest
Posts: n/a
 
      1st Sep 2005
Hi Christian,

There is a sample file at http://edferrero.m6.net/charting.aspx
Look for Conditional Chart Formatting.

Works much like Andy Pope's code.

Ed Ferrero
http://edferrero.m6.net/

> Hi, Jon!
>
> Jon Peltier schrieb:
>> Here's an introduction to conditional charting:
>> http://peltiertech.com/Excel/Charts/...nalChart1.html

>
> Thank you very much! Thats a great collection of tips, but thats not
> what I'm looking for. I don't want do modify the tables. I thougt about
> something like:
>
> with all bars do
> if cell.value < 2.5 then bar.color = green
> else bar.color = red
> end with
>
> in a skript assigned to the diagrams.
>
> The values will not be changing very often, so it doesn't need to be
> fast. If that's not possible, I think I manually will paint the few bars
> red that are above 2.5
>
> regards,
> Chriss



 
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
Color change for Column Chart John Microsoft Excel Programming 4 5th May 2010 03:11 AM
Change color of Autoshape in chart John Michl Microsoft Excel Programming 3 12th May 2007 03:14 AM
How to change color scheme in pie chart? =?Utf-8?B?Q2FtcHVzIFN0YWZm?= Microsoft Excel Charting 2 23rd May 2006 07:54 PM
help me to change the color of two series in a chart into the same KhanhNguyen Microsoft Excel Charting 2 21st Apr 2006 04:48 AM
Change the default color in a chart smeesh Microsoft Excel Charting 1 5th Jan 2004 11:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:02 AM.