Excel VBA 用于更改雷达图上的标记大小、颜色和透明度

标签 excel vba radar-chart

尝试在雷达图上分配自定义标记颜色和透明度级别时,我被 VBA 挡住了。我读过订单存在一些问题,但无论我在哪里尝试 .transparency 参数,我都会收到以下错误:对象不支持此属性或方法。

如果我在以下代码中注释掉 .transparency 行,我会得到一个很棒的雷达图,其中的标记由 rngColors 中的值着色。我只想让它们透明,这样底层的线图也可以通过。任何帮助或建议将不胜感激。

问候,
亚当

Sub colorPoints()

'Must select chart when running macro

  Dim x As Long
  Dim rngColors As Range

  Set rngColors = Range("H8:H57") 'set range of RGB color

  For x = 1 To ActiveChart.SeriesCollection(1).Points.Count
    With ActiveChart.SeriesCollection(1).Points(x)

        .Format.Fill.Solid
        .MarkerBackgroundColor = RGB(212, 142, rngColors(x))
        .transparency = 0.5 <-Error: 'Object doesn't support this property or method.'

    End With
Next

End Sub

编辑:感谢评论中的链接,以下代码在分配颜色后作为单独的宏运行时对我有用。不过这很棘手,我不知道为什么。首先我需要运行透明度代码(下),然后注释掉 .Solid,然后运行颜色代码(上),然后再次运行透明度代码(下),然后它就可以工作了。哎呀!我现在不太担心优化,但这似乎经常工作:
Sub transcheck()

' transcheck Macro

Dim cht As Chart
Dim Ser As Series
Dim lngIndex As Long
Dim lngChartType As XlChartType

Set cht = ActiveSheet.ChartObjects(1).Chart
Set Ser = cht.SeriesCollection(1)
lngChartType = Ser.ChartType
Ser.ChartType = xlColumnClustered

For lngIndex = 1 To 50
 With Ser.Format.Fill
   .Solid
   .Visible = True
   .transparency = 0.5
 End With

Ser.ChartType = lngChartType
Next
End Sub

最佳答案

关于Excel VBA 用于更改雷达图上的标记大小、颜色和透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27361262/

相关文章:

javascript - Chart.js 雷达图如何删除外部标签

jquery - jqplot 极 map 和雷达图的最佳替代品

C# ITypeInfo.GetContainingTypeLib 在传递 VBA 类的实时实例时失败

c# - 在解决方案资源管理器中将 Excel 文件添加到项目

excel - 在不均匀排序的 Excel 电子表格中查找一年前的值

vba - 如何使 Visual Basic 在 protected 工作表上工作(没有密码保护)

vba - 跨 MS Office 应用程序共享 VBA 模块

.net - 如何从 VBA 迭代 .NET HashTable 的键

vba - Excel vba - 多个条件和多个语句

javascript - 无法使极坐标图填充 Anychart 中的整个象限