|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cht As Chart, ser As Series
Set cht = Sheet1.ChartObjects("图表 3").Chart
cht.ClearToMatchColorStyle
cht.ApplyDataLabels xlDataLabelsShowNone
If Not Intersect(Sheet1.UsedRange, Target) Is Nothing Then
cht.SetSourceData Intersect(Sheet1.UsedRange, Target)
For Each ser In cht.FullSeriesCollection
arr = ser.Values
ma = Application.Max(arr): mi = Application.Min(arr)
ma1 = Application.Match(ma, arr, 0): mi1 = Application.Match(mi, arr, 0)
ser.XValues = Intersect(Sheet1.UsedRange, Target).Range("a1").End(xlToLeft).Resize(Intersect(Sheet1.UsedRange, Target).Rows.Count, 1)
ser.Points(ma1).ApplyDataLabels , , , , , True, True, True, , "|"
ser.Points(mi1).ApplyDataLabels , , , , , True, True, True, , "|"
ser.Points(ma1).Format.Fill.ForeColor.RGB = RGB(255, 0, 255)
ser.Points(mi1).Format.Fill.ForeColor.RGB = RGB(255, 0, 255)
Next
End If
End Sub
颜色需要可以自行更改,图形模式需要可以自行更改。
|
|