我正在为当前工作表
之后的工作表编写vba代码Sub InsertChartsAfterWorksheets()
Dim myWorksheet As Worksheet
Dim myChart As Chart
For Each myWorksheet In Worksheets
Set myChart = Charts.Add
myChart.ChartType = xlXYScatterLines
myChart.Move After:=myWorksheet
Next myWorksheet
End Sub
并且错误的图表,我需要改变什么错误???
答案 0 :(得分:2)
请阅读我对这个问题的评论......
我想你想在每个工作表后添加图表(显示为工作表)。
Dim wbk As Workbook
Dim wsh As Worksheet
Dim chrt As Chart
Set wbk = ThisWorkbook
For each wsh in wbk.Worksheets
Set chrt = wbk.Charts.Add(After:=wsh)
With chrt
'change some properties of chart
End With
Next
有关详细信息,请参阅:
Charts.Add method
Creating Charts in Excel 2003 Using Visual Basic for Applications Code