I want to iterate through the x values (categories) in the pivot chart.
If the x value equals cell C4 then make that bar color red.
Otherwise, the bars should be blue.
This doesn't do anything:
Sub color_chart()
Dim c As Chart
Dim s As Series
Dim iPoint As Long
Dim nPoint As Long
Charts("Chart 2").Activate
Set c = ActiveChart
Set s = c.SeriesCollection(1)
nPoint = s.Points.Count
For iPoint = 1 To nPoint
If s.XValues(iPoint) = Range("C4").Value Then
s.Points(iPoint).Interior.Color = RGB(255, 78, 0)
End If
Next iPoint
End Sub
More info:
Is there a way to make the color red on the bar which corresponds to the name that is chosen in the drop down list?
For example, for employee name let's say I choose Judith Blake from the drop down data validation list. I want the bar of Judith Blake in the pivot chart to be red. I want this to be done dynamically. So if I choose James Lewis for example in the drop down, the James Lewis bar becomes red and all others blue.
For reference, the chart is called Chart3 and the corresponding pivot table is PivotTable2.
Worksheet Image

Here (read only)/screenshots refer:
In action
If this is what you're looking to achieve - then see link / below in more detail:
*Note: ranges B5: c12 = user input/static entries to begin wih:
Helper data: complete list, unselected and selected, formulated as follows:
complete list (cell G5, array function)
unselected (cell H5):
Named ranges:
Not critical - but for parsimony, VB etc. may reference following:
complete (name), refers to:
selected, refers to:
unselected (name), refers to:
These are dynamic / variable length ranges (will always select down to final non-blank cell; if no populated cell in respective range, the cell where the first such entry would occur is selected)
drop-down (name), refers to:
Graph data:
Comprises col1_sel and col2_sel (colours 1/2 resp) as follows:
col1_sel
col2_sel
VB code:
Finally: see here for how to create macro pertainin to sheet, to be executed whenever specified target range of cell(s) is altered.
Below - I include bespoke/tailored code for the case in question:
Alternatively
Within the Private Sub Worksheet_Change VBA code above, you could include something like this to cyce through the bars and colour them as req (instead of the 'hack' I provide above which relies upon two series being defined etc.
This still requires helper tables to identify col_1 vs _2 etc.
Pre-requsities: