如何使每行分别包含图形

时间:2019-07-08 10:57:52

标签: excel vba

如何制作VBA脚本以使其包含-图形的所有行。该图是分散的,因此我无法添加一定范围的行,需要具有For参数,并相应地包含具有X和Y值的每一行。

我擅长编程,因此尝试了一些宏,但没有帮助。

    Dim i As Integer, k As Integer
    Dim ws As Worksheet

    Set ws = ThisWorkbook.Sheets("page1")
    For i = 4 To 155
        For k = 1 To 155    
            ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
            ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select

            ActiveChart.FullSeriesCollection(k).Name = ActiveSheet.Cells(i, 1)
            ActiveChart.FullSeriesCollection(k).XValues = ActiveSheet.Cells(i, 2)
            ActiveChart.FullSeriesCollection(k).Values = ActiveSheet.Cells(i, 3)
            k = k + 1
            i = i + 1
        Next k
    Next i  
End Sub

0 个答案:

没有答案