|
Kein さん ありがとうございます。
若干、手は加えたのですがどうしても
Seriesクラスのvalueプロパティを設定できません。とエラーが出ます。
.Values = .Name & "!$A$" & i & ":$K$" & i
何が原因でしょうか??
環境はwinXP,エクセル2003になります。
Sub MyChart1()
Dim Ch As ChartObject, MyCh As ChartObject
Dim Lp As Single, Wp As Single, Hp As Single
With ActiveSheet
If .ChartObjects.Count > 0 Then
For Each Ch In .ChartObjects
If Ch.TopLeftCell.Address = "$A$1" Then
Ch.Delete
End If
Next
End If
With .Range("A1:L9")
Lp = .Left + 11
Wp = .Width - 10
Hp = .Height - 10
End With
Set MyCh = .ChartObjects.Add(Lp, 0, Wp, Hp)
MyCh.Chart.ChartType = xlLine
For i = 49 To 53
If Not IsEmpty(.Cells(i, 2).Value) Then
With MyCh.Chart.SeriesCollection.NewSeries
.XValues = .Name & "!$A$48:$K$48"
.Values = .Name & "!$A$" & i & ":$K$" & i
End With
End If
Next i
MyCh.Chart.HasTitle = True
MyCh.Chart.ChartTitle.Text = .Range("A47").Value
End With
With MyCh.Chart.ChartTitle
.Font.Size = 15
.Border.ColorIndex = 5
End With
With MyCh.Axes(xlCategory)
.HasTitle = True
.AxisTitle.Text = "日付"
.AxisTitle.Font.Size = 12
End With
With MyCh.Axes(xlValue)
.HasTitle = True
.AxisTitle.Text = "データ2"
.AxisTitle.Font.Size = 14
End With
Set MyCh = Nothing
End Sub
|
|