- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
8#
發表於 2014-8-18 10:40
| 只看該作者
回復 7# Scott090
幫你練一下功,試試看- Option Explicit
- Sub Ex()
- Dim X(), Y(), XLeft As Single, Ytop As Single, i As Integer
- Dim P As PlotArea, C As Chart, S As Shapes
- Set C = ActiveSheet.ChartObjects(1).Chart '指定圖表
- Set P = C.PlotArea
- X = C.SeriesCollection(1).XValues 'X軸數值
- Y = C.SeriesCollection(1).Values 'Y軸數值
- i = 3 '指定數值點.
- With C.Axes(1) 'xlCategory 'X軸
- XLeft = P.InsideWidth / (.MaximumScale - .MinimumScale)
- '點數間距的寬度
- End With
- With C.Axes(2) 'xlValue 'Y軸
- Ytop = P.InsideHeight / (.MaximumScale - .MinimumScale)
- ''點數間距的高度
- End With
- XLeft = P.InsideLeft + (XLeft * X(i))
- Ytop = P.InsideTop + P.InsideHeight - (Ytop * Y(i))
- Set S = C.Shapes
- If S.Count <> 0 Then
- C.Parent.Activate
- S.SelectAll
- Selection.Delete
- End If
- With C.Shapes.AddShape(msoShapeRectangle, Left:=XLeft, Top:=Ytop, Width:=100, Height:=50)
- .TextFrame.Characters.Text = "附加說明1:" & Chr(10) & "X: " & X(i) & Space(5) & "Y: " & Y(i)
- End With
- C.Parent.Parent.Activate
- End Sub
複製代碼 |
|