Advertisement
Advertisement
| 10.07.2008 at 09:25AM PDT, ID: 23794345 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: |
Private Sub Worksheet_Activate()
Dim shp As Shape
Dim bShape As Boolean
Dim cht As ChartObject
Dim ser As Series
Dim AxisX As Axis, AxisY As Axis
Dim dX As Double, dY As Double, dSlope As Double, dAngle As Double
Dim xData As Variant, yData As Variant
Set cht = ActiveSheet.ChartObjects("chart 10")
Set AxisX = cht.Chart.Axes(xlCategory)
Set AxisY = cht.Chart.Axes(xlValue)
dX = AxisX.Width / (AxisX.MaximumScale - AxisX.MinimumScale)
dY = AxisY.Height / (AxisY.MaximumScale - AxisY.MinimumScale)
For sern = 1 To cht.Chart.SeriesCollection.Count
Set ser = cht.Chart.SeriesCollection(sern)
For Each shp In cht.Chart.Shapes
Select Case sern
Case 1
shname = "redArrow"
Case 2
shname = "greenArrow"
Case 3
shname = "yellowArrow"
End Select
If shp.Name = shname Then
Exit For
End If
Next
With ser
xData = .XValues
yData = .Values
dSlope = Application.WorksheetFunction.Slope(yData, xData) * dY / dX
dAngle = 180 / Application.Pi() * Application.Atan2(1, dSlope)
If dAngle < 0 Then dAngle = dAngle + 360
shp.Rotation = -dAngle
End With
Next sern
End Sub
|