2017-01-24 24 views
0

下面的代碼根據數據點標籤值更改了條的顏色,但是我有幾個具有相同值的點,而我只想要帶有文本的點被着色。如何將代碼修改爲基於軸文本的顏色?基於軸文本而不是數據點值的彩條 - EXCEL VBA

x1 = ws2.Cells(icounter, 3) 
Set ch = ActiveChart 
Set s = ch.SeriesCollection(1) 


nPoint = s.Points.Count 
For iPoint = 1 To nPoint 
If Format(x1, "0.00%") = s.Points(iPoint).DataLabel.Text Then 
s.Points(iPoint).Format.Fill.ForeColor.RGB = RGB(192, 0, 0) 
End If 
Next iPoint 

例如,在以下的畫面,杆比「BK EMEA CE」其他被着色,因爲這些條具有相同的數據點的值作爲BK EMEA CE。我只想BK EMEA CE紅色

for example, in picture below, bars other than "bK EMEA ce" is colored because those bars have the same data point value as bk emea ce. I only want bk emea ce colored red

回答

0

想通了。

交換

If Format(x1, "0.00%") = s.Points(iPoint).DataLabel.Text Then 

If ws2.Cells(icounter, 2) = s.XValues(iPoint) Then 
相關問題