標題:
VBA 畫Trend Chart問題
[打印本頁]
作者:
taiwan16699
時間:
2014-12-6 00:27
標題:
VBA 畫Trend Chart問題
擷取程式碼如下,我要從第6個sheet到底的每個sheets都要依同樣方法繪製trend chart
最後跑出應用程式或物件定義上錯誤
可以麻煩幫忙嗎?
新手,不大會寫,請多包涵
Sub hihi()
Sheets("rawdata").Select
Cells(300, 1).End(xlUp).Select
endDD = Selection.Row
Cells(5, 1000).End(xlToLeft).Select
endRR = Selection.Column
For F = 6 To Sheets.Count
Sheets(F).Select
'Range(Cells(1, k), Cells(2, k)).Select
ActiveSheet.Shapes.AddChart.Select '增加圖形
ActiveChart.ChartType = xlLineMarkers '圖形類型
ActiveChart.ApplyLayout (5) '圖表樣式
ActiveChart.SetSourceData Source:=Sheets(F).Range(Cells(1, k), Cells(2, k)) '資料範圍<----1004
Next
End Sub
作者:
taiwan16699
時間:
2014-12-6 00:52
沒貼完整修正如下
Sub hihi()
Sheets("rawdata").Select
Cells(300, 1).End(xlUp).Select
endDD = Selection.Row
Cells(1, 1000).End(xlToLeft).Select
endRR = Selection.Column
For F = 6 To Sheets.Count
For K = 1 To endRR
Range(Cells(1, 1), Cells(2, K)).Select
'Range(Cells(1, k), Cells(2, k)).Select
ActiveSheet.Shapes.AddChart.Select '增加圖形
ActiveChart.ChartType = xlLineMarkers '圖形類型
ActiveChart.SetSourceData Source:=Sheets(F).Range(Cells(1, 1), Cells(2, K)) '資料範圍
ActiveChart.ApplyLayout (5) '圖表樣式
ActiveChart.ChartTitle.Select
Selection.delete
ActiveChart.Axes(xlValue).AxisTitle.Select
Selection.delete
Next
Next
End Su
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)