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 批量生成條形圖代碼