473,395 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Changing Individual Column Colours in a barchart

2
Hi,

I need to be able to change individual column's colour in a series in bar charts, i.e.

IF Column Value > Target THEN
Column Colour = Green
ELSEIF Column Value = Target THEN
Column Colour = Orange
ELSE Column Colour = Red
END IF

I need to be able to do it for all the charts in the Workbook and for each column in each chart.

But I don't know how to do this in VB or even if it can be done.

Does anyone have any suggestions?

Regards, Charls
Apr 19 '07 #1
1 1565
SammyB
807 Expert 512MB
Assuming that you only have Chart sheets, this code changes anything with a value > 12 to green. If you have charts that are embedded on Worksheets, then you must first iterate through the Worksheets collection, then for each worksheet, iterate through the ChartObjects collection. I left the elseif's and color to you. To figure out the rest, record a macro and set a column manually. Let me know if you have embedded charts. HTH --Sam
Expand|Select|Wrap|Line Numbers
  1. Sub Macro2()
  2.     Dim c As Chart
  3.     For Each c In ActiveWorkbook.Charts
  4.         Dim s As Series
  5.         Set s = c.SeriesCollection(1)
  6.         For i = 1 To s.Points.Count
  7.             If s.Values(i) > 12 Then s.Points(i).Interior.ColorIndex = 10
  8.         Next i
  9.     Next c
  10. End Sub
Apr 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dimitri pater | last post by:
Hello, I am looking for a Python tool to create graphs and charts on a webpage. Chartdirector is too expensive for me. A simple script for creating a barchart should be sufficient as a starting...
1
by: Ike | last post by:
Suppose I have a table, and it is populated with many rows already. However, I realise I structured something wrong in my table. I dont want to have to go back and repopulate the entire table. ...
4
by: david.graham18 | last post by:
Hi I spotted some nice code to change the background colour of a web page to one of four different colours at random but I can't find it now! The method was to select a number at random from 1...
16
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables...
6
by: Brett Miller | last post by:
Hi, I need to change the colour of certain items in a listbox depending on criteria I receive from my dataset? How would this be accomplished? Thanks in advance... BM
11
by: Hugh Janus | last post by:
OK, this is driving me crazy! As far as I can tell it should work. It compiles fine. I am saving the fore and back colour of a RTB to the registry like this: Srx.SetValue("ForeColour",...
3
by: Aziz | last post by:
1. I have a shopping basket DataGrid with a list of products. What I want to do is when the user clicks on a row, a button will become visible/be created that allows user to edit the quantity. The...
3
Mague
by: Mague | last post by:
Hey, I need to change colours in a richtextbox. I am making a simple html editor. i want to make the tags different colours. I have searched google so please dont say search google. I also use...
7
by: emlimeng | last post by:
Hello, I have a label on the form to draw people's attention so they do not forget to input the data in a particular section. e.g. "Please carefully check all the options on the form". I hope I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.