首页 > 解决方案 > Series.Formula 将字符(例如逗号)更改为分号

问题描述

我编写了代码来遍历数据(如下所示)并根据类别收集数据。这些数据将被添加到专用数据系列中并绘制在 ScatterPlot 上。
在此处输入图像描述

Series.Formula更改一些字符,例如逗号、分号(下图)并弹出错误。

以前的样子:
在此处输入图像描述

它的外观如何:
在此处输入图像描述

Dim mySeries As Series    
For Each mySeries In ActiveSheet.ChartObjects("Test").Chart.SeriesCollection
    For Each c In Source.Range("U7:U13")
               
        If c = mySeries.Name Then
                    
            k = 0
            Do While Cells(c.row, c.Column) = Cells(c.row + k, c.Column)
                k = k + 1
            Loop
            k = k - 1
                
            srsX = "{"
            srsY = "{"
            For j = c.row To c.row + k
                srsX = srsX & (Cells(j, c.Column + 2)) & "\" '& Application.International(xlListSeparator)
                srsY = srsY & (Cells(j, c.Column + 1)) & "\" '& Application.International(xlListSeparator)
                        
            Next j
            srsX = Left(srsX, Len(srsX) - 1) & "}"
            srsY = Left(srsY, Len(srsY) - 1) & "}"
                    
            With ActiveSheet.ChartObjects("Test").Chart.SeriesCollection
                trashme = "=SERIES(""" & mySeries.Name & """" & Application.International(xlListSeparator) & srsX & Application.International(xlListSeparator) & srsY & Application.International(xlListSeparator) & mySeries.PlotColorIndex & ")"
                MsgBox trashme
                mySeries.Formula = "=SERIES(""" & mySeries.Name & """" & Application.International(xlListSeparator) & srsX & Application.International(xlListSeparator) & srsY & Application.International(xlListSeparator) & mySeries.PlotColorIndex & ")"
            End With
        End If    
                
    Next c
Next mySeries

标签: excelvbacharts

解决方案


推荐阅读