vba 批量生成条形图代码
Posted Alex0111
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vba 批量生成条形图代码相关的知识,希望对你有一定的参考价值。
Sub hong3()
‘
‘ 宏3 宏d
Dim a, b As Integer
Dim str As String
For a = 227 To 947 Step 15
b = a + 5
str = "Sheet1!B" + CStr(a) + ":G" + CStr(b)
sh = ActiveSheet.Shapes.AddChart2(216, xlBarClustered)
sh.Select
ActiveChart.SetSourceData Source:=Range(str)
ActiveChart.SetElement (msoElementChartTitleNone)
ActiveChart.SetElement (msoElementPrimaryValueGridLinesNone)
ActiveChart.SetElement (msoElementLegendRight)
ActiveChart.SetElement (msoElementPrimaryValueAxisNone)
ActiveChart.HasAxis(xlCategory) = True
With sh
.Top = Range("j" + CStr(a - 1)).Top
.Left = Range("j" + CStr(a - 1)).Left
End With
ActiveChart.Axes(xlCategory).Select
Selection.MajorTickMark = xlOutside
ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
Next a
End Sub
以上是关于vba 批量生成条形图代码的主要内容,如果未能解决你的问题,请参考以下文章