我在寫一個腳本來創建圖表,每行一個在我的表格中。這個想法是得到一個線圖來顯示歷史。使用vba腳本創建圖表
表看起來是這樣的:
date modem capacity used
16/01/2017 PUT 20gb 54% 20/01/2017 73% 21/01/2017 80%
16/01/2017 PATITIFA 20gb 73% 20/01/2017 79% 21/01/2017 90%
16/01/2017 HAWAIKI 40gb 44% 20/01/2017 55% 21/01/2017 70%
16/01/2017 NUI 60gb 48% 20/01/2017 61% 21/01/2017 80%
16/01/2017 ITI 20gb 75% 20/01/2017 84% 21/01/2017 90%
16/01/2017 huawei 20gb 37% 20/01/2017 45% 21/01/2017 60%
正試圖創建表我的VBA腳本是在這裏:
Sub addchart()
Dim chartPut, chartPatitifa, chartHawaiki, chartNui, chartIti, chartHuawei As Chart
Dim iRow, iCol As Long
Dim date1, date2, date3, date4, date5, date6 As String
Dim conso1, conso2, conso3, conso4, conso5, conso6 As String
Dim forfait As String
Dim modem As String
iRow = 2
iCol = 1
Do Until IsEmpty(Cells(iRow, 1))
date1 = Cells(iRow, 1).Value
modem = Cells(iRow, 2).Value
forfait = Cells(iRow, 3).Value
conso1 = Cells(iRow, 4).Value
date2 = Cells(iRow, 5).Value
conso2 = Cells(iRow, 6).Value
date3 = Cells(iRow, 7).Value
conso3 = Cells(iRow, 8).Value
date4 = Cells(iRow, 9).Value
conso4 = Cells(iRow, 10).Value
date5 = Cells(iRow, 11).Value
conso5 = Cells(iRow, 12).Value
date6 = Cells(iRow, 13).Value
conso6 = Cells(iRow, 14).Value
Set chartPut = Charts.Add
With chartPut
.SetSourceData Source:=Range("STATS!$A$2:$F$2")
.SeriesCollection(1).Name = modem
'conso values
.SeriesCollection(1).Values = "conso1; conso2; conso3; conso4; conso5; conso6"
'date values
.SeriesCollection(1).XValues = "date1; date2; date3; date4; date5; date6 "
End With
Loop
End Sub
的事情是,我不能讓「CONSO」和「日期」值作爲數據值被接受到表中。...... 有什麼想法?
所以,這是一個*圖*你正在嘗試創建,而不是*表* –