Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Changing chart colours using VBA

Is it possible to change the colours of bars on a chart depending on the
value. For example, if a value is positive, colour the bar green, if
negative, colour it red. The 'invert if negative' check box within Excel sets
the bar to white if negative
  #2   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Changing chart colours using VBA

With my limited knowledge, it seems that each number would need to be a
different series in order to change the color of each individual bar. Unless
your numbers are set up to have all negative numbers in one series and
positive in another.

If that is a possibility than changing the color of the bars is a matter of
recording a macro and cleaning it up.

Hope that at least gets you started.

"TommoUK" wrote:

Is it possible to change the colours of bars on a chart depending on the
value. For example, if a value is positive, colour the bar green, if
negative, colour it red. The 'invert if negative' check box within Excel sets
the bar to white if negative

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Changing chart colours using VBA


This code does the trick for me (it is from an earlier posting). Just
select the chart before you run the code.

Sub ColorColumns()

Dim vntValues As Variant
Dim intSeries As Integer
Dim intPoint As Integer

With ActiveChart
For intSeries = 1 To .SeriesCollection.Count
With .SeriesCollection(intSeries)
vntValues = .Values
For intPoint = 1 To .Points.Count
If vntValues(intPoint) < 1 Then
' red column
..Points(intPoint).Interior.Color = _
RGB(255, 0, 0)
ElseIf vntValues(intPoint) 0 Then
' green column
..Points(intPoint).Interior.Color = _
RGB(0, 255, 0)
End If
Next
End With
Next
End With

End Sub


--
czywrg
------------------------------------------------------------------------
czywrg's Profile: http://www.excelforum.com/member.php...o&userid=31051
View this thread: http://www.excelforum.com/showthread...hreadid=509752

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
Changing Tab Colours BOXMAN Excel Worksheet Functions 2 August 24th 06 01:59 AM
Changing colours in chart witzman Charts and Charting in Excel 2 May 31st 05 06:58 AM
multiple or changing colours in a data table on an excel chart fo. Kerri Buxton Charts and Charting in Excel 2 December 23rd 04 07:39 PM
changing colours on stacked bar chart sphenisc Excel Programming 1 June 10th 04 03:32 AM
Changing Colours on Worksheet Jahson Excel Programming 3 May 20th 04 12:54 PM


All times are GMT +1. The time now is 06:07 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"