[問題] vba增加標題及座標軸標題已刪文

看板Office作者 (精靈)時間5年前 (2020/08/04 16:45), 5年前編輯推噓0(0016)
留言16則, 2人參與, 5年前最新討論串1/1
Sub chart() Dim i%, arr, arr1, mychart As chart On Error Resume Next If Sheet1.ChartObjects.Count > 0 Then Sheet1.ChartObjects.Delete arr = Range("d2:g146") Sheet1.ChartObjects.Add(ActiveCell.Left, ActiveCell.Top, 400, 150).chart Set mychart = Sheet1.ChartObjects(1).chart With mychart .ChartType = xlXYScatterLinesNoMarkers .HasLegend = False .Axes(xlValue).MajorGridlines.Delete .Axes(xlValue).Delete With .Axes(xlCategory) .MajorTickMark = xlNone .TickLabelPosition = xlNone .Format.Line.Weight = 2 End With End With For i = 1 To UBound(arr) mychart.SeriesCollection.NewSeries With mychart.SeriesCollection(i) .XValues = "sheet1!$d$" & i + 2 & ":$e$" & i + 2 .Values = "sheet1!$f$" & i + 2 & ":$g$" & i + 2 If Cells(i + 2, 3) <= 90 Then .Format.Line.ForeColor.RGB = RGB(0, 0, 255) ElseIf Cells(i + 2, 3) <= 180 Then .Format.Line.ForeColor.RGB = RGB(0, 0, 255) ElseIf Cells(i + 2, 3) <= 270 Then .Format.Line.ForeColor.RGB = RGB(0, 0, 255) Else .Format.Line.ForeColor.RGB = RGB(0, 0, 255) End If .Format.Line.EndArrowheadStyle = msoArrowheadWide .Format.Line.EndArrowheadWidth = msoArrowheadNone .Format.Line.Weight = 0.75 End With Next i End Sub 想詢問若上方vba程式想加 1.圖表標題‘’風向及風速‘’ 2.y軸標題"風速(m/s)" 3.在圖上加曲線及副座標軸、標題"溫度",資料範圍為U3~U146 另外想詢問垂直格線可以只顯示一條嗎?(比如在X=72(X軸中間的位置)處顯示垂直格線就 好),若可以的話要怎麼加在此VBA語法中呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.137.207.14 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Office/M.1596530701.A.EC0.html ※ 編輯: fishman0612 (223.137.207.14 臺灣), 08/04/2020 16:48:03

08/04 17:28, 5年前 , 1F
1.圖表標題,with mychart內加,setelement(..charttitle.
08/04 17:28, 1F

08/04 17:28, 5年前 , 2F
..)、hastitle、charttitle.text
08/04 17:28, 2F

08/04 17:28, 5年前 , 3F
2.y軸標題,with mychart內加,setelement(...
08/04 17:28, 3F

08/04 17:28, 5年前 , 4F
primaryvalueaxistitle...)、hastitle(於axes(...).
08/04 17:28, 4F

08/04 17:28, 5年前 , 5F
hastitle)、axistitle.text
08/04 17:28, 5F

08/04 17:28, 5年前 , 6F
3.資料再加入數列內,該數列設為副座標軸axisgroup,副座
08/04 17:28, 6F

08/04 17:28, 5年前 , 7F
標軸標題setelement(...secondaryvalueaxistitle...)、
08/04 17:28, 7F

08/04 17:28, 5年前 , 8F
axes(...).axistitle.text
08/04 17:28, 8F

08/04 17:28, 5年前 , 9F
只顯示一條,新增個數列(xy散佈圖),以誤差線
08/04 17:28, 9F

08/04 18:44, 5年前 , 10F
感謝S大,不好意思,因為我完全沒寫過vba,內文是現
08/04 18:44, 10F

08/04 18:44, 5年前 , 11F
成的程式,想詢問讀取副座標軸的資料該如何加入此段
08/04 18:44, 11F

08/04 18:44, 5年前 , 12F
程式中呢?感謝您的回覆!
08/04 18:44, 12F

08/04 20:02, 5年前 , 13F
加入於迴圈結束後,newseries新增u3:u146這個範圍到數列,
08/04 20:02, 13F

08/04 20:02, 5年前 , 14F
values就為"工作表1!u3:u146",接著axisgroup設為副座標軸
08/04 20:02, 14F

08/04 20:02, 5年前 , 15F
;標題setelement(...secondaryvalueaxistitle...)、axes(
08/04 20:02, 15F

08/04 20:02, 5年前 , 16F
...).axistitle.text
08/04 20:02, 16F
文章代碼(AID): #1VAI0Dx0 (Office)
文章代碼(AID): #1VAI0Dx0 (Office)