Option Explicit□□□□□□□□□□□□□□ '変数の宣言を強制する
'*-------------------------------------------------*
' 共通変数
'*-------------------------------------------------*
Dim gOldStatusBar As String
Dim gOldZoomValue As Integer□□□□□□□□'Excel2007ではZoom値が50%や100%でない場合オブジェクト描画位置がズレるバグがあるため一時的に100%にしておき後で元に戻す
Dim gChartStartX As Double□□□□□□□□ '線表開始位置のX座標
Dim gDateChartStart As Date□□□□□□□□ '進捗表全体の開始日
Dim gDateChartEnd As Date□□□□□□□□ '進捗表全体の終了日
Dim gChartCellWidthPerPoint As Double□□ 'セルの幅(ポイント単位):Range.Widthで取得のみ可能(設定はできない)
Dim gChartLineLastPoint(1) As Double□□□□'前回の点:Lineの始点(X座標,Y座標)
Dim gChartLineNewPoint(1) As Double□□□□ '新しい点:Lineの終点(X座標,Y座標)
Dim gObjectLineNo As Integer
'*-------------------------------------------------*
' 共通定数
'*-------------------------------------------------*
Const X As Integer = 0
Const Y As Integer = 1
Const STATUSBAR_WAIT As String = "しばらくお待ちください..."
Const NAME_HEADER_LINE As String = "ProgressChartLine"
Const NAME_HEADER_PLAN_SQR As String = "PlanSquare"
Const NAME_HEADER_ACHV_SQR As String = "AchievementSquare"
Const CLM_WORK_ITEM_NAME As Integer = 2
Const CLM_STICK_COLOR As Integer = 3
Const CLM_DATE_START As Integer = 4
Const CLM_DATE_END As Integer = 5
Const CLM_PROGRESS_RATE As Integer = 6
Const CLM_CHART_START As Integer = 7
Const CHART_CELL_WIDTH As Double = 1.88□□ 'セルの幅(標準フォントの半角文字の幅単位):Range.ColumnWidthで取得/設定とも可能
Const CHART_CELL_HEIGHT As Double = 13.5□□'セルの高さ:Range.Height(取得のみ)、Range.RowHeight(取得/設定)で共通の単位
'***************************************************
' 進捗管理ツール
' 作成日 : 2009/01/25~2009/2/xx
' メイン関数
'***************************************************
Sub ProgressChartMain()
□□Dim rowPos As Integer
□□Dim clmPos As Integer
□□Dim chartStartRow As Integer□□□□□□'線表開始行
□□Dim chartEndRow As Integer□□□□□□ '線表終了行
□□Dim dateToday As Date□□□□□□□□ '今日の日付
□□Dim workItemDateStart As Date□□□□ 'rosPos行目の作業項目の開始日
□□Dim workItemDateEnd As Date□□□□□□ 'rosPos行目の作業項目の終了日
□□Dim workItemProgressRate As Double□□ 'rosPos行目の作業項目の進捗率
□□Dim sh As Object
□□Call StartUp
□□Call ClearAllObject
□□Call SetStileOfSheet
□□'各データの検出
□□For rowPos = 1 To 1000□□□□□□□□ '無限ループに陥らないために1000で打ち止めにする
□□□□If Cells(rowPos, CLM_DATE_START).Value = "開始日" And Cells(rowPos, CLM_DATE_END).Value = "終了日" Then
□□□□□□'進捗表全体の開始日と終了日の取得
□□□□□□gDateChartStart = Cells(rowPos + 1, CLM_DATE_START).Value
□□□□□□gDateChartEnd = Cells(rowPos + 1, CLM_DATE_END).Value
□□□□□□'線表開始行の取得
□□□□□□chartStartRow = rowPos + 2
□□□□□□
□□□□ElseIf Cells(rowPos, CLM_WORK_ITEM_NAME).Value = "全体進捗" Then
□□□□□□'線表終了行の取得
□□□□□□chartEndRow = rowPos
□□□□□□Exit For
□□□□End If
□□Next
□□'線表開始位置のX座標の取得
□□gChartStartX = Range(Columns(1), Columns(CLM_CHART_START - 1)).Width
□□'今日の日付の取得
□□dateToday = Date
□□'最初(上部)の線を引く
□□Call DrawLine(ChangeDateToX(dateToday), _
□□□□□□□□Range(Rows(1), Rows(chartStartRow - 4)).Height, _
□□□□□□□□ChangeDateToX(dateToday), _
□□□□□□□□Range(Rows(1), Rows(chartStartRow - 2)).Height + CHART_CELL_HEIGHT / 2)
□□'線表の描画
□□For rowPos = chartStartRow To chartEndRow - 1
□□□□'作業項目がない場合
□□□□If Cells(rowPos, CLM_DATE_START).Value = "" Or _
□□□□□□Cells(rowPos, CLM_DATE_END).Value = "" Or _
□□□□□□Cells(rowPos, CLM_PROGRESS_RATE).Value = "" Then
□□□□□□
□□□□□□'ポイントをTodayとしてLineを描画する
□□□□□□Call DrawLine(gChartLineLastPoint(X), _
□□□□□□□□□□□□gChartLineLastPoint(Y), _
□□□□□□□□□□□□ChangeDateToX(dateToday), _
□□□□□□□□□□□□gChartLineLastPoint(Y) + CHART_CELL_HEIGHT)
□□□□'作業項目がある場合
□□□□Else
□□□□□□'rowPos行目の作業項目の開始日の取得
□□□□□□'(進捗表全体の開始日よりも前の場合は表からはみ出ないように補正する)
□□□□□□workItemDateStart = MaxDate(gDateChartStart, Cells(rowPos, CLM_DATE_START).Value)
□□
□□□□□□'rowPos行目の作業項目の終了日の取得
□□□□□□'(進捗表全体の終了日よりも後の場合は表からはみ出ないように補正する)
□□□□□□workItemDateEnd = MinDate(gDateChartEnd, Cells(rowPos, CLM_DATE_END).Value)
□□
□□□□□□'rowPos行目の作業項目の進捗率の取得
□□□□□□workItemProgressRate = Cells(rowPos, CLM_PROGRESS_RATE).Value
□□□□□□'予定を描画する
□□□□□□Set sh = ActiveSheet
□□□□□□With sh.Shapes.AddShape(msoShapeRectangle, _
□□□□□□□□□□□□□□□□□□ChangeDateToX(workItemDateStart) - 3, _
□□□□□□□□□□□□□□□□□□Range(Rows(1), Rows(rowPos - 1)).Height + 2, _
□□□□□□□□□□□□□□□□□□ChangeDateToX(workItemDateEnd) - ChangeDateToX(workItemDateStart) + 3, _
□□□□□□□□□□□□□□□□□□CHART_CELL_HEIGHT - 4)
□□□□□□□□.Name = NAME_HEADER_PLAN_SQR & Str(gObjectLineNo)
□□□□□□□□.Fill.ForeColor.RGB = Cells(rowPos, CLM_STICK_COLOR).Interior.Color
□□□□□□□□.Line.Weight = 1.5
□□□□□□End With
□□□□□□'実績を描画する
□□□□□□With sh.Shapes.AddShape(msoShapeRectangle, _
□□□□□□□□□□□□□□□□□□ChangeDateToX(workItemDateStart) - 3, _
□□□□□□□□□□□□□□□□□□Range(Rows(1), Rows(rowPos - 1)).Height + 5, _
□□□□□□□□□□□□□□□□□□(ChangeDateToX(workItemDateEnd) - ChangeDateToX(workItemDateStart) + 3) * workItemProgressRate, _
□□□□□□□□□□□□□□□□□□CHART_CELL_HEIGHT - 9)
□□□□□□□□.Name = NAME_HEADER_ACHV_SQR & Str(gObjectLineNo)
□□□□□□□□.Fill.ForeColor.RGB = RGB(63, 63, 63)
□□□□□□□□.Line.Weight = 0
□□□□□□End With
□□□□□□'進捗率に応じたLineを描画する
□□□□□□If workItemProgressRate <= 0 Then
□□□□□□□□gChartLineNewPoint(X) = ChangeDateToX(MinDate(workItemDateStart, dateToday))
□□□□□□ElseIf workItemProgressRate >= 1 Then
□□□□□□□□gChartLineNewPoint(X) = ChangeDateToX(MaxDate(workItemDateEnd, dateToday))
□□□□□□Else
'□□□□□□□□gChartLineNewPoint(X) = ChangeDateToX(workItemDateStart + WorksheetFunction.RoundDown((workItemDateEnd - workItemDateStart) * workItemProgressRate, 0))
□□□□□□□□ gChartLineNewPoint(X) = ChangeDateToX(workItemDateStart) + (ChangeDateToX(workItemDateEnd) - ChangeDateToX(workItemDateStart)) * workItemProgressRate
□□□□□□End If
□□□□□□Call DrawLine(gChartLineLastPoint(X), _
□□□□□□□□□□□□gChartLineLastPoint(Y), _
□□□□□□□□□□□□gChartLineNewPoint(X), _
□□□□□□□□□□□□gChartLineLastPoint(Y) + CHART_CELL_HEIGHT)
□□□□End If
□□Next
□□
□□'最後(下部)の線を引く
□□Call DrawLine(gChartLineLastPoint(X), _
□□□□□□□□gChartLineLastPoint(Y), _
□□□□□□□□ChangeDateToX(dateToday), _
□□□□□□□□gChartLineLastPoint(Y) + CHART_CELL_HEIGHT / 2)
'□□Selection.ShapeRange.Group
'□□ActiveSheet.Shapes.Range(Array(5, 6)).Group
'□□ActiveSheet.Shapes(chartLineNameArray(0)).Select
'□□ActiveSheet.Shapes.Range(chartLineNameArray(1)).Select
'□□Selection.Group.Name = "aaa"
□□Call ShutDown
End Sub
'***************************************************
' マクロ開始処理
'***************************************************
Sub StartUp()
□□'ステータスバーの表示を変更する
□□gOldStatusBar = Application.DisplayStatusBar
□□Application.DisplayStatusBar = True
□□Application.StatusBar = STATUSBAR_WAIT
□□'画面を停止する
□□Application.ScreenUpdating = False
□□'ズーム値を一時的に100%にする
□□gOldZoomValue = ActiveWindow.Zoom
□□ActiveWindow.Zoom = 100
□□'グローバル変数の初期化
□□gObjectLineNo = 0
End Sub
'***************************************************
' マクロ終了処理
'***************************************************
Sub ShutDown()
□□'スクロールバーをセットする
□□ActiveWindow.ScrollColumn = 1
□□ActiveWindow.ScrollRow = 1
□□'カーソル位置をセットする
□□Cells(1, 1).Select
□□'ズーム値を一時的に100%にする
□□ActiveWindow.Zoom = gOldZoomValue
□□'画面の停止を解除する
□□Application.ScreenUpdating = True
□□'ステータスバーの表示を元に戻す
□□Application.StatusBar = False
□□Application.DisplayStatusBar = gOldStatusBar
End Sub
'***************************************************
' シートの体裁整え
'***************************************************
Sub SetStileOfSheet()
□□'列の幅と行の高さを整える(セルの幅は標準フォントの半角文字単位で設定する)
□□Range(Columns(CLM_CHART_START), Columns(CLM_CHART_START).End(xlToRight)).ColumnWidth = CHART_CELL_WIDTH
□□Range(Rows(1), Rows(1).End(xlDown)).RowHeight = CHART_CELL_HEIGHT
□□'セルの幅をポイント単位で取得する
□□gChartCellWidthPerPoint = Columns(CLM_CHART_START).Width
End Sub
'***************************************************
' オブジェクトの削除
'***************************************************
Sub ClearAllObject()
□□Dim sh As Object
□□'"Bottun 1"を除き、シート内のオブジェクトを全て削除する
□□For Each sh In ActiveSheet.Shapes
'□□□□If sh.Name <> "Button 1" Then
□□□□If Left(sh.Name, Len(NAME_HEADER_LINE)) = NAME_HEADER_LINE Or _
□□□□□□Left(sh.Name, Len(NAME_HEADER_PLAN_SQR)) = NAME_HEADER_PLAN_SQR Or _
□□□□□□Left(sh.Name, Len(NAME_HEADER_ACHV_SQR)) = NAME_HEADER_ACHV_SQR Then
□□□□□□sh.Delete
□□□□End If
□□Next
End Sub
'***************************************************
' 日付をx座標に変換する
'***************************************************
Function ChangeDateToX(InputDate As Date) As Double
□□Dim OutputX As Double
□□
□□If InputDate < gDateChartStart Then
□□□□InputDate = gDateChartStart
□□ElseIf InputDate > gDateChartEnd Then
□□□□InputDate = gDateChartEnd
□□End If
□□OutputX = gChartStartX _
□□□□□□ + ((Year(InputDate) - Year(gDateChartStart)) * 36 _
□□□□□□ + (Month(InputDate) - Month(gDateChartStart)) * 3 _
□□□□□□ + WorksheetFunction.RoundDown(Day(InputDate) / 10, 0) _
□□□□□□ + 0.5) * gChartCellWidthPerPoint
□□ChangeDateToX = OutputX
End Function
'***************************************************
' 線を引く
'***************************************************
Sub DrawLine(InputStartX As Double, InputStartY As Double, InputEndX As Double, InputEndY As Double)
□□Dim sh As Object
□□Set sh = ActiveSheet.Shapes.AddLine(InputStartX, InputStartY, InputEndX, InputEndY)
□□With sh
□□□□.Name = NAME_HEADER_LINE & Str(gObjectLineNo)
□□□□.Line.Weight = 2.25
□□□□.Line.ForeColor.RGB = vbRed
□□End With
□□gChartLineLastPoint(X) = InputEndX
□□gChartLineLastPoint(Y) = InputEndY
□□gObjectLineNo = gObjectLineNo + 1
End Sub
'***************************************************
' 日付を比較して大きい方を返す
'***************************************************
Function MaxDate(InputDate1 As Date, InputDate2 As Date) As Date
□□Dim OutputDate As Date
□□
□□If InputDate1 > InputDate2 Then
□□□□OutputDate = InputDate1
□□Else
□□□□OutputDate = InputDate2
□□End If
□□MaxDate = OutputDate
End Function
'***************************************************
' 日付を比較して小さい方を返す
'***************************************************
Function MinDate(InputDate1 As Date, InputDate2 As Date) As Date
□□Dim OutputDate As Date
□□
□□If InputDate1 < InputDate2 Then
□□□□OutputDate = InputDate1
□□Else
□□□□OutputDate = InputDate2
□□End If
□□MinDate = OutputDate
End Function
'*-------------------------------------------------*
' 共通変数
'*-------------------------------------------------*
Dim gOldStatusBar As String
Dim gOldZoomValue As Integer□□□□□□□□'Excel2007ではZoom値が50%や100%でない場合オブジェクト描画位置がズレるバグがあるため一時的に100%にしておき後で元に戻す
Dim gChartStartX As Double□□□□□□□□ '線表開始位置のX座標
Dim gDateChartStart As Date□□□□□□□□ '進捗表全体の開始日
Dim gDateChartEnd As Date□□□□□□□□ '進捗表全体の終了日
Dim gChartCellWidthPerPoint As Double□□ 'セルの幅(ポイント単位):Range.Widthで取得のみ可能(設定はできない)
Dim gChartLineLastPoint(1) As Double□□□□'前回の点:Lineの始点(X座標,Y座標)
Dim gChartLineNewPoint(1) As Double□□□□ '新しい点:Lineの終点(X座標,Y座標)
Dim gObjectLineNo As Integer
'*-------------------------------------------------*
' 共通定数
'*-------------------------------------------------*
Const X As Integer = 0
Const Y As Integer = 1
Const STATUSBAR_WAIT As String = "しばらくお待ちください..."
Const NAME_HEADER_LINE As String = "ProgressChartLine"
Const NAME_HEADER_PLAN_SQR As String = "PlanSquare"
Const NAME_HEADER_ACHV_SQR As String = "AchievementSquare"
Const CLM_WORK_ITEM_NAME As Integer = 2
Const CLM_STICK_COLOR As Integer = 3
Const CLM_DATE_START As Integer = 4
Const CLM_DATE_END As Integer = 5
Const CLM_PROGRESS_RATE As Integer = 6
Const CLM_CHART_START As Integer = 7
Const CHART_CELL_WIDTH As Double = 1.88□□ 'セルの幅(標準フォントの半角文字の幅単位):Range.ColumnWidthで取得/設定とも可能
Const CHART_CELL_HEIGHT As Double = 13.5□□'セルの高さ:Range.Height(取得のみ)、Range.RowHeight(取得/設定)で共通の単位
'***************************************************
' 進捗管理ツール
' 作成日 : 2009/01/25~2009/2/xx
' メイン関数
'***************************************************
Sub ProgressChartMain()
□□Dim rowPos As Integer
□□Dim clmPos As Integer
□□Dim chartStartRow As Integer□□□□□□'線表開始行
□□Dim chartEndRow As Integer□□□□□□ '線表終了行
□□Dim dateToday As Date□□□□□□□□ '今日の日付
□□Dim workItemDateStart As Date□□□□ 'rosPos行目の作業項目の開始日
□□Dim workItemDateEnd As Date□□□□□□ 'rosPos行目の作業項目の終了日
□□Dim workItemProgressRate As Double□□ 'rosPos行目の作業項目の進捗率
□□Dim sh As Object
□□Call StartUp
□□Call ClearAllObject
□□Call SetStileOfSheet
□□'各データの検出
□□For rowPos = 1 To 1000□□□□□□□□ '無限ループに陥らないために1000で打ち止めにする
□□□□If Cells(rowPos, CLM_DATE_START).Value = "開始日" And Cells(rowPos, CLM_DATE_END).Value = "終了日" Then
□□□□□□'進捗表全体の開始日と終了日の取得
□□□□□□gDateChartStart = Cells(rowPos + 1, CLM_DATE_START).Value
□□□□□□gDateChartEnd = Cells(rowPos + 1, CLM_DATE_END).Value
□□□□□□'線表開始行の取得
□□□□□□chartStartRow = rowPos + 2
□□□□□□
□□□□ElseIf Cells(rowPos, CLM_WORK_ITEM_NAME).Value = "全体進捗" Then
□□□□□□'線表終了行の取得
□□□□□□chartEndRow = rowPos
□□□□□□Exit For
□□□□End If
□□Next
□□'線表開始位置のX座標の取得
□□gChartStartX = Range(Columns(1), Columns(CLM_CHART_START - 1)).Width
□□'今日の日付の取得
□□dateToday = Date
□□'最初(上部)の線を引く
□□Call DrawLine(ChangeDateToX(dateToday), _
□□□□□□□□Range(Rows(1), Rows(chartStartRow - 4)).Height, _
□□□□□□□□ChangeDateToX(dateToday), _
□□□□□□□□Range(Rows(1), Rows(chartStartRow - 2)).Height + CHART_CELL_HEIGHT / 2)
□□'線表の描画
□□For rowPos = chartStartRow To chartEndRow - 1
□□□□'作業項目がない場合
□□□□If Cells(rowPos, CLM_DATE_START).Value = "" Or _
□□□□□□Cells(rowPos, CLM_DATE_END).Value = "" Or _
□□□□□□Cells(rowPos, CLM_PROGRESS_RATE).Value = "" Then
□□□□□□
□□□□□□'ポイントをTodayとしてLineを描画する
□□□□□□Call DrawLine(gChartLineLastPoint(X), _
□□□□□□□□□□□□gChartLineLastPoint(Y), _
□□□□□□□□□□□□ChangeDateToX(dateToday), _
□□□□□□□□□□□□gChartLineLastPoint(Y) + CHART_CELL_HEIGHT)
□□□□'作業項目がある場合
□□□□Else
□□□□□□'rowPos行目の作業項目の開始日の取得
□□□□□□'(進捗表全体の開始日よりも前の場合は表からはみ出ないように補正する)
□□□□□□workItemDateStart = MaxDate(gDateChartStart, Cells(rowPos, CLM_DATE_START).Value)
□□
□□□□□□'rowPos行目の作業項目の終了日の取得
□□□□□□'(進捗表全体の終了日よりも後の場合は表からはみ出ないように補正する)
□□□□□□workItemDateEnd = MinDate(gDateChartEnd, Cells(rowPos, CLM_DATE_END).Value)
□□
□□□□□□'rowPos行目の作業項目の進捗率の取得
□□□□□□workItemProgressRate = Cells(rowPos, CLM_PROGRESS_RATE).Value
□□□□□□'予定を描画する
□□□□□□Set sh = ActiveSheet
□□□□□□With sh.Shapes.AddShape(msoShapeRectangle, _
□□□□□□□□□□□□□□□□□□ChangeDateToX(workItemDateStart) - 3, _
□□□□□□□□□□□□□□□□□□Range(Rows(1), Rows(rowPos - 1)).Height + 2, _
□□□□□□□□□□□□□□□□□□ChangeDateToX(workItemDateEnd) - ChangeDateToX(workItemDateStart) + 3, _
□□□□□□□□□□□□□□□□□□CHART_CELL_HEIGHT - 4)
□□□□□□□□.Name = NAME_HEADER_PLAN_SQR & Str(gObjectLineNo)
□□□□□□□□.Fill.ForeColor.RGB = Cells(rowPos, CLM_STICK_COLOR).Interior.Color
□□□□□□□□.Line.Weight = 1.5
□□□□□□End With
□□□□□□'実績を描画する
□□□□□□With sh.Shapes.AddShape(msoShapeRectangle, _
□□□□□□□□□□□□□□□□□□ChangeDateToX(workItemDateStart) - 3, _
□□□□□□□□□□□□□□□□□□Range(Rows(1), Rows(rowPos - 1)).Height + 5, _
□□□□□□□□□□□□□□□□□□(ChangeDateToX(workItemDateEnd) - ChangeDateToX(workItemDateStart) + 3) * workItemProgressRate, _
□□□□□□□□□□□□□□□□□□CHART_CELL_HEIGHT - 9)
□□□□□□□□.Name = NAME_HEADER_ACHV_SQR & Str(gObjectLineNo)
□□□□□□□□.Fill.ForeColor.RGB = RGB(63, 63, 63)
□□□□□□□□.Line.Weight = 0
□□□□□□End With
□□□□□□'進捗率に応じたLineを描画する
□□□□□□If workItemProgressRate <= 0 Then
□□□□□□□□gChartLineNewPoint(X) = ChangeDateToX(MinDate(workItemDateStart, dateToday))
□□□□□□ElseIf workItemProgressRate >= 1 Then
□□□□□□□□gChartLineNewPoint(X) = ChangeDateToX(MaxDate(workItemDateEnd, dateToday))
□□□□□□Else
'□□□□□□□□gChartLineNewPoint(X) = ChangeDateToX(workItemDateStart + WorksheetFunction.RoundDown((workItemDateEnd - workItemDateStart) * workItemProgressRate, 0))
□□□□□□□□ gChartLineNewPoint(X) = ChangeDateToX(workItemDateStart) + (ChangeDateToX(workItemDateEnd) - ChangeDateToX(workItemDateStart)) * workItemProgressRate
□□□□□□End If
□□□□□□Call DrawLine(gChartLineLastPoint(X), _
□□□□□□□□□□□□gChartLineLastPoint(Y), _
□□□□□□□□□□□□gChartLineNewPoint(X), _
□□□□□□□□□□□□gChartLineLastPoint(Y) + CHART_CELL_HEIGHT)
□□□□End If
□□Next
□□
□□'最後(下部)の線を引く
□□Call DrawLine(gChartLineLastPoint(X), _
□□□□□□□□gChartLineLastPoint(Y), _
□□□□□□□□ChangeDateToX(dateToday), _
□□□□□□□□gChartLineLastPoint(Y) + CHART_CELL_HEIGHT / 2)
'□□Selection.ShapeRange.Group
'□□ActiveSheet.Shapes.Range(Array(5, 6)).Group
'□□ActiveSheet.Shapes(chartLineNameArray(0)).Select
'□□ActiveSheet.Shapes.Range(chartLineNameArray(1)).Select
'□□Selection.Group.Name = "aaa"
□□Call ShutDown
End Sub
'***************************************************
' マクロ開始処理
'***************************************************
Sub StartUp()
□□'ステータスバーの表示を変更する
□□gOldStatusBar = Application.DisplayStatusBar
□□Application.DisplayStatusBar = True
□□Application.StatusBar = STATUSBAR_WAIT
□□'画面を停止する
□□Application.ScreenUpdating = False
□□'ズーム値を一時的に100%にする
□□gOldZoomValue = ActiveWindow.Zoom
□□ActiveWindow.Zoom = 100
□□'グローバル変数の初期化
□□gObjectLineNo = 0
End Sub
'***************************************************
' マクロ終了処理
'***************************************************
Sub ShutDown()
□□'スクロールバーをセットする
□□ActiveWindow.ScrollColumn = 1
□□ActiveWindow.ScrollRow = 1
□□'カーソル位置をセットする
□□Cells(1, 1).Select
□□'ズーム値を一時的に100%にする
□□ActiveWindow.Zoom = gOldZoomValue
□□'画面の停止を解除する
□□Application.ScreenUpdating = True
□□'ステータスバーの表示を元に戻す
□□Application.StatusBar = False
□□Application.DisplayStatusBar = gOldStatusBar
End Sub
'***************************************************
' シートの体裁整え
'***************************************************
Sub SetStileOfSheet()
□□'列の幅と行の高さを整える(セルの幅は標準フォントの半角文字単位で設定する)
□□Range(Columns(CLM_CHART_START), Columns(CLM_CHART_START).End(xlToRight)).ColumnWidth = CHART_CELL_WIDTH
□□Range(Rows(1), Rows(1).End(xlDown)).RowHeight = CHART_CELL_HEIGHT
□□'セルの幅をポイント単位で取得する
□□gChartCellWidthPerPoint = Columns(CLM_CHART_START).Width
End Sub
'***************************************************
' オブジェクトの削除
'***************************************************
Sub ClearAllObject()
□□Dim sh As Object
□□'"Bottun 1"を除き、シート内のオブジェクトを全て削除する
□□For Each sh In ActiveSheet.Shapes
'□□□□If sh.Name <> "Button 1" Then
□□□□If Left(sh.Name, Len(NAME_HEADER_LINE)) = NAME_HEADER_LINE Or _
□□□□□□Left(sh.Name, Len(NAME_HEADER_PLAN_SQR)) = NAME_HEADER_PLAN_SQR Or _
□□□□□□Left(sh.Name, Len(NAME_HEADER_ACHV_SQR)) = NAME_HEADER_ACHV_SQR Then
□□□□□□sh.Delete
□□□□End If
□□Next
End Sub
'***************************************************
' 日付をx座標に変換する
'***************************************************
Function ChangeDateToX(InputDate As Date) As Double
□□Dim OutputX As Double
□□
□□If InputDate < gDateChartStart Then
□□□□InputDate = gDateChartStart
□□ElseIf InputDate > gDateChartEnd Then
□□□□InputDate = gDateChartEnd
□□End If
□□OutputX = gChartStartX _
□□□□□□ + ((Year(InputDate) - Year(gDateChartStart)) * 36 _
□□□□□□ + (Month(InputDate) - Month(gDateChartStart)) * 3 _
□□□□□□ + WorksheetFunction.RoundDown(Day(InputDate) / 10, 0) _
□□□□□□ + 0.5) * gChartCellWidthPerPoint
□□ChangeDateToX = OutputX
End Function
'***************************************************
' 線を引く
'***************************************************
Sub DrawLine(InputStartX As Double, InputStartY As Double, InputEndX As Double, InputEndY As Double)
□□Dim sh As Object
□□Set sh = ActiveSheet.Shapes.AddLine(InputStartX, InputStartY, InputEndX, InputEndY)
□□With sh
□□□□.Name = NAME_HEADER_LINE & Str(gObjectLineNo)
□□□□.Line.Weight = 2.25
□□□□.Line.ForeColor.RGB = vbRed
□□End With
□□gChartLineLastPoint(X) = InputEndX
□□gChartLineLastPoint(Y) = InputEndY
□□gObjectLineNo = gObjectLineNo + 1
End Sub
'***************************************************
' 日付を比較して大きい方を返す
'***************************************************
Function MaxDate(InputDate1 As Date, InputDate2 As Date) As Date
□□Dim OutputDate As Date
□□
□□If InputDate1 > InputDate2 Then
□□□□OutputDate = InputDate1
□□Else
□□□□OutputDate = InputDate2
□□End If
□□MaxDate = OutputDate
End Function
'***************************************************
' 日付を比較して小さい方を返す
'***************************************************
Function MinDate(InputDate1 As Date, InputDate2 As Date) As Date
□□Dim OutputDate As Date
□□
□□If InputDate1 < InputDate2 Then
□□□□OutputDate = InputDate1
□□Else
□□□□OutputDate = InputDate2
□□End If
□□MinDate = OutputDate
End Function