Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Christian Münscher
 
Posts: n/a
Default Bar chart: change color of a bar to red if value > x?

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
  #2   Report Post  
Jon Peltier
 
Posts: n/a
Default

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

  #3   Report Post  
Christian Münscher
 
Posts: n/a
Default

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
  #4   Report Post  
Andy Pope
 
Posts: n/a
Default

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
  #5   Report Post  
Ed Ferrero
 
Posts: n/a
Default

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
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
How to change a bar to line in a combo chart? KimD Charts and Charting in Excel 2 August 10th 05 06:23 PM
How do I change the order of how excel builds a chart? big al Charts and Charting in Excel 2 May 26th 05 08:47 AM
Urgent Chart Assistance Brent E Charts and Charting in Excel 1 May 10th 05 09:09 AM
Urgent Chart Assistance Requested Brent E Excel Discussion (Misc queries) 0 May 9th 05 11:01 PM
ho to change in the bubble chart the bubble position and size laszlo Charts and Charting in Excel 0 March 25th 05 04:45 PM


All times are GMT +1. The time now is 12:26 PM.

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"