Sub ローソク足チャート() Dim rangch As Range Dim evra As String Dim evrb As Integer Dim kari2 As Range evra = Application.Version evrb = Val(Left(evra, 2)) 'グラフ作成 If heikin = 0 Then If evrb = 12 Then For i = 4 To GYOU Cells(i, 8) = Cells(GYOU + 4 - i, 1) Cells(i, 9) = Cells(GYOU + 4 - i, 2) Cells(i, 10) = Cells(GYOU + 4 - i, 3) Cells(i, 11) = Cells(GYOU + 4 - i, 4) Cells(i, 12) = Cells(GYOU + 4 - i, 5) Cells(i, 13) = Cells(GYOU + 4 - i, 6) Next Range(Cells(3, 1), Cells(3, 6)).Copy Range(Cells(3, 8), Cells(3, 13)) Columns("H:H").Select Selection.NumberFormatLocal = "yyyy/m/d" Range("H1").Select Set rangch = Range(Cells(4, 8), Cells(GYOU, 13)) Else Set rangch = Range(Cells(4, 1), Cells(GYOU, 6)) End If Else Set rangch = Range(Cells(4, 1), Cells(GYOU, 5)) End If Range("A4").Select ActiveSheet.ChartObjects.Add(5, 18, 550, 250).Select ActiveChart.SetSourceData Source:=rangch, PlotBy _ :=xlColumns ActiveChart.Location Where:=xlLocationAsObject, Name:=shname If heikin = 0 Then ActiveChart.ChartType = xlStockVOHLC Else ActiveChart.ChartType = xlStockOHLC End If 'データのある日のみ表示 ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale If heikin = 0 Then ActiveChart.Axes(xlCategory, xlSecondary).CategoryType = xlCategoryScale End If '軸の反転 If evrb <> 12 Or heikin = 1 Then With ActiveChart.Axes(xlCategory) .AxisBetweenCategories = True .ReversePlotOrder = True End With End If '東証平均の軸移動 If heikin = 1 Then With ActiveChart.Axes(xlValue) .TickLabelPosition = xlHigh .TickLabels.NumberFormatLocal = "#,##0" End With End If '凡例カット ActiveChart.HasLegend = False '右縦列文字調整 With ActiveChart.Axes(xlValue) .TickLabels.Font.Size = 8 If heikin = 0 Then .MaximumScale = .MaximumScale * 2 .MinimumScale = 0 Else .MinimumScale = Application.Round((yasune - 100), -2) End If End With '左縦列文字調整 If heikin = 0 Then With ActiveChart.Axes(xlValue, xlSecondary) .TickLabels.Font.Size = 8 If .MaximumScale < 1001 Then .MinimumScale = Int(Int(yasune * 0.8) / 10) * 10 Else .MinimumScale = Int(Int(yasune * 0.8) / 100) * 100 End If End With End If '下列文字調整 With ActiveChart.Axes(xlCategory).TickLabels .Font.Size = 8 .NumberFormatLocal = "yy/mm/dd" .Orientation = xlDownward End With 'グラフ線の調整 ActiveChart.ChartGroups(1).GapWidth = 50 If heikin = 0 Then ActiveChart.SeriesCollection(1).Interior.ColorIndex = 35 ActiveChart.ChartGroups(2).GapWidth = 50 End If 'プロットエリアの色 ActiveChart.PlotArea.Interior.ColorIndex = 2 '終了処理 Range("G1").Select ActiveSheet.Protect DrawingObjects:=True Application.StatusBar = "-- チャート作成完了 -- " End Sub