2軸の折れ線グラフの作成にて、セルA1・B1の数値を変更することにより、ワークシート上のグラフの参照位置を全て置換えるというものなのですが、
.SetSourceData Source:=ActiveSheet.・・・・
ここで(実行エラー1004、アプリ又はオブジェクトの定義エラー)どう変更すればよいのでしょうか?よろしくお願いします。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row > 1 Or Target.Column > 2 Then Exit Sub
Dim r,C1,C2 As String
Dim ch As ChartObject
Dim minRow,maxRow As Long
minRow = 50:maxRow = 100
If Range("A1").Value >= minRow And Range("A1").Value <= maxRow _
And Range("B1").Value >= minRow And Range("B1").Value <= maxRow Then
For Each ch In ActiveSheet.ChartObjects
ch.Activate
With ActiveChart
c1 = .SeriesCollection(1).Name
c2 = .SeriesCollection(2).Name
r = c1 & Range("A1").Value & ":" & c1 & Range("B1").Value & "," _
& c2 & Range("A1").Value & ":" & c2 & Range("B1").Value
.SetSourceData Source:=ActiveSheet.Range(r), PlotBy:=xlColumns
.SeriesCollection(1).Name = c1
.SeriesCollection(2).Name = c2
End With
Next
End Sub