|
仅供参考,网上复制粘贴的,那位老师有更简洁的代码请赐教
Sub aa()
ActiveSheet.ChartObjects("图表 1").Activate
n = ActiveChart.FullSeriesCollection(1).Points.Count
For i = 1 To n
addr = Cells(2 + i, 6).Address
r = Split(get_RGB(addr), ",")(0)
g = Split(get_RGB(addr), ",")(1)
b = Split(get_RGB(addr), ",")(2)
ActiveChart.FullSeriesCollection(1).Points(i).Format.Fill.ForeColor.RGB = RGB(r, g, b)
Next
End Sub
Function get_RGB(addr) As String
' addr = ActiveWorkbook.Application.ThisCell.Address
c = Range(addr).Interior.Color
r = c Mod 256
g = (c - r) / 256 Mod 256
b = (c - r - g * 256) / 256 ^ 2
get_RGB = r & "," & g & "," & b
End Function |
|