|
例えば B3 セルの左上端にグラフの左上端を合わせるなら・・
Sub Ch_Copy()
Dim i As Integer
Dim Lp As Single, Tp As Single
Dim Fom As String, NewFm As String
Sheets("MeasData").ChartObjects("グラフ 13").Duplicate _
.Chart.Location xlLocationAsObject, "HistRead"
With Sheets("HistRead")
Lp = .Range("B3").Left: Tp = .Range("B3").Top
With .ChartObjects(.ChartObjects.Count)
.Left = Lp: .Top = Tp
For i = 1 To .Chart.SeriesCollection.Count
Fom = .Chart.SeriesCollection(i).Formula
NewFm = Replace(Fom, "MeasData", "HistRead")
.Chart.SeriesCollection(i).Formula = NewFm
Next i
End With
.Activate
End With
End Sub
ついでに大きさを、B3:G16 に合わせるなら
Dim Wp As Single, Hp As Single
を追加宣言し
With Sheets("HistRead")
With Range("B3:G16")
Lp = .Left: Tp = .Top: Wp = .Width: Hp = .Height
End With
With .ChartObjects(.ChartObjects.Count)
.Left = Lp: .Top = Tp: Width = Wp: .Height = Hp
というように、幅と高さも指定すれば良いでしょう。
|
|