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語法中呢?