VBA插入曲线图怎么设置数值轴属性
我写的代码如下Sub逐个插入图表()'在指定位置作图'清除已有图表nohang=Range("c65536").End(xlUp).RowForEachrInSheets...
我写的代码如下
Sub 逐个插入图表()
'在指定位置作图
'清除已有图表
nohang = Range("c65536").End(xlUp).Row
For Each r In Sheets("销售数据").ChartObjects
r.Delete
Next
Dim ab As Range
Dim e As Range
Dim bbb As ChartObject
Dim xx As Integer, yy As Integer, zz As Integer
For m = 1 To 3 Step 1
xx = (m - 1) * 20 + 4
yy = (m - 1) * 20 + 22
zz = m * 3
Set e = Range(Range(Cells(441, 2), Cells(nohang, 2)), Range(Cells(441, zz), Cells(nohang, zz + 2)))
Set ab = Range("b" & xx, "i" & yy) '生成图表的位置
Set bbb = ActiveSheet.ChartObjects.Add(ab.Left, ab.Top, ab.Width, ab.Height)
With bbb.Chart
.ChartType = xlLine '折线图
.SetSourceData Source:=e '数据源
With .TickLabels.Font '数值轴字体改为9号
.Name = "宋体"
.FontStyle = "常规"
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
With .Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlHundredThousands
.HasDisplayUnitLabel = True
End With '图表属性设置结束
End With
Set e = Nothing
Set bbb = Nothing
Next m
End Sub
调试的时候弹出如下错误
就是要改变红框里的数字大小,代码要怎么改 展开
Sub 逐个插入图表()
'在指定位置作图
'清除已有图表
nohang = Range("c65536").End(xlUp).Row
For Each r In Sheets("销售数据").ChartObjects
r.Delete
Next
Dim ab As Range
Dim e As Range
Dim bbb As ChartObject
Dim xx As Integer, yy As Integer, zz As Integer
For m = 1 To 3 Step 1
xx = (m - 1) * 20 + 4
yy = (m - 1) * 20 + 22
zz = m * 3
Set e = Range(Range(Cells(441, 2), Cells(nohang, 2)), Range(Cells(441, zz), Cells(nohang, zz + 2)))
Set ab = Range("b" & xx, "i" & yy) '生成图表的位置
Set bbb = ActiveSheet.ChartObjects.Add(ab.Left, ab.Top, ab.Width, ab.Height)
With bbb.Chart
.ChartType = xlLine '折线图
.SetSourceData Source:=e '数据源
With .TickLabels.Font '数值轴字体改为9号
.Name = "宋体"
.FontStyle = "常规"
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
With .Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlHundredThousands
.HasDisplayUnitLabel = True
End With '图表属性设置结束
End With
Set e = Nothing
Set bbb = Nothing
Next m
End Sub
调试的时候弹出如下错误
就是要改变红框里的数字大小,代码要怎么改 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询