水曜日, 11月 26, 2008

GPSから速度域色分け走行距離ー標高グラフ作成

日-水曜の結果
 走行距離 10km
 走行時間 30min
 平均心拍数 130回/min
 消費カロリー 300kcal
 食後体重 68.4kg
 体脂肪 *%
 ウエスト *cm

GPSから速度域色分け走行距離ー標高グラフ作成。

 走行距離ー標高グラフを時速区分で色分け。
 コードは次のとおり。
Dim n As Integer
n = 2

ActiveSheet.Shapes.AddLine(100, 100, 400, 100).Select '500m100km
Selection.ShapeRange.Line.Weight = 1
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)


For n = 2 To 1600 Step 1
y = Cells(2 + n, 13) / 5
x = Cells(2 + n, 5) * 3
ActiveSheet.Shapes.AddLine(100 + x, 200 - y, 100 + x + 1, 200 - y - 1).Select
Selection.ShapeRange.Line.Weight = 1
c = Cells(1 + n, 6)
If c < 10 Then
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
End If
If c > 10 Then
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 250)
End If
If c > 20 Then
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 255, 255)
End If
If c > 30 Then
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 255, 0)
End If
If c > 40 Then
Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 255, 0)
End If
If c > 50 Then
Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 0, 0)
End If
Cells(1, 1).Select
Cells(1, 1) = n + 3
Next



ActiveSheet.Shapes.AddLine(10, 50, 20, 50).Select
Selection.ShapeRange.Line.Weight = 2
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
ActiveSheet.Shapes.AddLine(10, 60, 20, 60).Select
Selection.ShapeRange.Line.Weight = 2
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 250)
ActiveSheet.Shapes.AddLine(10, 70, 20, 70).Select
Selection.ShapeRange.Line.Weight = 2
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 255, 255)
ActiveSheet.Shapes.AddLine(10, 80, 20, 80).Select
Selection.ShapeRange.Line.Weight = 2
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 255, 0)
ActiveSheet.Shapes.AddLine(10, 90, 20, 90).Select
Selection.ShapeRange.Line.Weight = 2
Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 255, 0)
ActiveSheet.Shapes.AddLine(10, 100, 20, 100).Select
Selection.ShapeRange.Line.Weight = 2
Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 0, 0)

ActiveSheet.Shapes.SelectAll
Selection.ShapeRange.Group