Link to home
Start Free TrialLog in
Avatar of jnikodym
jnikodym

asked on

Excel VBA, Bar Chart. Change bar color based on cell value

I have a bar chart in Excel.  The chart is displaying data from Column C and D.  Column C is a job description and column D is estimated hours to complete the job.  In Column E i have some text with Categories.  Each category has its own color.  I would like the bars in my chart to be color coded based on the category they are in.  Is this possible to do using some VBA code in Excel?
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Is it possible to rearrange the data at all? It might make this easy to do manually.

Also, can you post an example workbook?
Avatar of jnikodym
jnikodym

ASKER

I don't want to do it manually.  I have a button on the sheet that has vba code behind it that automatically creates the excel gantt chart.  It all works great, but i would just like to be able to categorize the bar lines with colors.
Without a sample workbook, it is harder to give a solution in this case - but in your scenario, if you are NOT using a regular built-in Excel chart, you might be able to use conditional formatting on your gantt chart (depending on how you produced your gantt chart).
I am using a stacked bar chart which you can manipulate a little to make it a gantt chart.  I just need the correct vba code to step through the bars to look for a certain value in my data set and color the bars based on that value.
ASKER CERTIFIED SOLUTION
Avatar of psteff
psteff
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial