[算表] VBA 作圖參照問題
軟體:Excel
版本:2010
目前有個產量EXCEL檔案只有一個Sheet,目前已經做出可以作圖的VBA code(如下)
想要將裡面的SheetA1 改寫成 本檔案的第一個工作頁
這樣之後換檔案執行VBA就不用再改Sheet name
有嘗試過以ActiveWorkbook.Worksheets(1)取代,但是還是出問題
我的產量有值的只有10000筆,作圖的結果會算到10700多筆,有時甚至不給RUN
請教各位大大該怎麼修正比較好?
Sub Production_History()
Dim chartA As Chart
Dim i As Long
i = Worksheets("SheetA1").UsedRange.Rows.Count
Set chartA = Charts.add(After:=Worksheets(Worksheets.Count))
With chartA
.Name = "產量-用量"
.ChartType = xlXYScatter
.SeriesCollection.NewSeries
.SeriesCollection(1).Name = "=""產量"""
.SeriesCollection(1).XValues = "='SheetA1'!$R$4:$R$" & i
.SeriesCollection(1).Values = "='SheetA1'!$C$4:$C$" & i
.SeriesCollection.NewSeries
.SeriesCollection(2).Name = "=""用量"""
.SeriesCollection(2).XValues = "='SheetA1'!$R$4:$R$" & i
.SeriesCollection(2).Values = "='SheetA1'!$O$4:$O$" & i
.SeriesCollection(2).AxisGroup = 2
End With
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.126.14.166
※ 文章網址: https://www.ptt.cc/bbs/Office/M.1550999254.A.B21.html
※ 編輯: van6499 (59.126.14.166), 02/24/2019 17:08:11
→
02/24 17:19,
5年前
, 1F
02/24 17:19, 1F
→
02/24 17:21,
5年前
, 2F
02/24 17:21, 2F
→
02/24 17:22,
5年前
, 3F
02/24 17:22, 3F
→
02/24 17:22,
5年前
, 4F
02/24 17:22, 4F
→
02/24 17:23,
5年前
, 5F
02/24 17:23, 5F
→
02/24 17:24,
5年前
, 6F
02/24 17:24, 6F
→
02/24 17:25,
5年前
, 7F
02/24 17:25, 7F
→
02/24 17:27,
5年前
, 8F
02/24 17:27, 8F
→
02/24 17:27,
5年前
, 9F
02/24 17:27, 9F
→
02/24 17:32,
5年前
, 10F
02/24 17:32, 10F
→
02/24 17:32,
5年前
, 11F
02/24 17:32, 11F
→
02/24 17:33,
5年前
, 12F
02/24 17:33, 12F
→
02/24 17:40,
5年前
, 13F
02/24 17:40, 13F
→
02/24 17:46,
5年前
, 14F
02/24 17:46, 14F
→
02/24 17:47,
5年前
, 15F
02/24 17:47, 15F
→
02/24 17:47,
5年前
, 16F
02/24 17:47, 16F
→
02/24 17:48,
5年前
, 17F
02/24 17:48, 17F
→
02/24 17:48,
5年前
, 18F
02/24 17:48, 18F