【发布时间】:2021-02-19 01:43:58
【问题描述】:
我在 .HasTitle = True 处遇到错误 438。 chtChart 小节有问题,因为我将 .charttype 放在第三行,Excel 总是提示我有 438 错误 编辑代码:
Dim chtChart As ChartObject
Dim maxscale As Long, LastRowOfA As Long
Dim xAxes As Axis, yAxes As Axis
Set chtChart = ActiveSheet.ChartObjects(1)
maxscale = ActiveSheet.Cells(LastRowOfA, 1)
LastRowOfA = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
With chtChart
.HasTitle = True
.ChartTitle.Text = "X VS Y"
.ChartType = xlXYScatterLinesNoMarkers
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.XValues = ActiveSheet.Range("A2:A" & LastRowOfA)
.Values = ActiveSheet.Range(Range("B2:B" & LastRowOfB))
End With
Set xAxes = .Axes(xlCategory, xlPrimary)
With xAxes
.HasTitle = True
.AxisTitle.Text = "Category (X) Axis"
.MinimumScale = 0
.MaximumScale = maxscale
.MajorUnit = tbData
End With
Set yAxes = .Axes(xlValue, xlPrimary)
With yAxes
.HasTitle = True
.AxisTitle.Text = "Category (Y) Axis"
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
End With
End With
【问题讨论】:
-
您尚未将
chtChart设置为图表对象...ColumnARngData上的单元格格式是什么? -
我该怎么做?是否设置了 chtChart = ActiveSheet.ChartObjects?格式一般
-
图表已经存在了吗?我看不到你的床单...
-
图表不存在。