![](/img/trans.png)
[英]Excel VBA .AddChart Method 'SetSource Data' of Object' _chart' failed
[英]Method name of object _chart failed
我收到Run Time error 1004 :Method name of object _chart failed
嘗試命名圖表時Run Time error 1004 :Method name of object _chart failed
。 有時會運行,有時卻不會。 這是導致錯誤的部分,(整個宏真的很長,因此我還沒有全部發布。)
繪制直方圖的3D col圖表:
Range("U1:R23").Select
Charts.Add
ActiveChart.ChartType = xlCylinderCol
ActiveChart.Name = "mcChart" -----------> Error
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Dynamic Weight Chasing Histogram" & Chr(10) & "Local SWT ,File:" & Name & ", Roadforce-Check Spin" & Chr(10) & "assembly after dimensions changed, Old software"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "weights(Oz)"
Charts("mcChart").SeriesCollection(1).XValues = Array(0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, "4-5", "5-6", "6-7", "7-8", "8-9", "9-10")
.SeriesCollection([4]).Interior.Color = RGB(139, 0, 0) ' dark red
.SeriesCollection([3]).Interior.Color = RGB(205, 92, 92) 'indian red
.SeriesCollection([2]).Interior.Color = RGB(128, 0, 128) 'magenta
.SeriesCollection([1]).Interior.Color = RGB(144, 238, 144) 'light green
End With
如果您可以找到解決此問題的方法,請告訴我。
您可以修改代碼並查看它是否有效嗎?
dim newChart as Chart
Range("U1:R23").Select
Set newChart = Charts.Add
With newChart
.ChartType = xlCylinderCol
.Name = "mcChart" & Format(now, "hhmmss")
'setting other properties
End With
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.