分享

Excel 如何把数据转换为K线图

 sumiaolingwan 2016-12-31
  1. Sub Macro2()
  2. '
  3. ' Macro2 Macro
  4. ' 宏由 User 录制,时间: 2016-5-6
  5. '

  6. '
  7.     Range("A1:A59").Select
  8.     ActiveWindow.SmallScroll Down:=-66
  9.     Charts.Add
  10.     ActiveChart.ChartType = xlLine
  11.     ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:A59"), PlotBy _
  12.         :=xlColumns
  13.     ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
  14.     With ActiveChart
  15.         .HasTitle = False
  16.         .Axes(xlCategory, xlPrimary).HasTitle = False
  17.         .Axes(xlValue, xlPrimary).HasTitle = False
  18.     End With
  19.     ActiveChart.HasLegend = False
  20.     ActiveChart.PlotArea.Select
  21.     With Selection.Border
  22.         .ColorIndex = 16
  23.         .Weight = xlThin
  24.         .LineStyle = xlContinuous
  25.     End With
  26.     Selection.Interior.ColorIndex = xlNone
  27.     ActiveChart.Axes(xlValue).MajorGridlines.Select
  28.     With Selection.Border
  29.         .ColorIndex = 15
  30.         .Weight = xlHairline
  31.         .LineStyle = xlContinuous
  32.     End With
  33.     ActiveChart.PlotArea.Select
  34.     ActiveChart.Axes(xlValue).Select
  35.     With Selection.Border
  36.         .Weight = xlHairline
  37.         .LineStyle = xlAutomatic
  38.     End With
  39.     With Selection
  40.         .MajorTickMark = xlNone
  41.         .MinorTickMark = xlNone
  42.         .TickLabelPosition = xlNextToAxis
  43.     End With
  44.     ActiveChart.Axes(xlCategory).Select
  45.     With ActiveChart.Axes(xlCategory)
  46.         .CrossesAt = 1
  47.         .TickLabelSpacing = 7
  48.         .TickMarkSpacing = 1
  49.         .AxisBetweenCategories = True
  50.         .ReversePlotOrder = False
  51.     End With
  52.     With Selection.Border
  53.         .Weight = xlHairline
  54.         .LineStyle = xlAutomatic
  55.     End With
  56.     With Selection
  57.         .MajorTickMark = xlOutside
  58.         .MinorTickMark = xlInside
  59.         .TickLabelPosition = xlNextToAxis
  60.     End With
  61.     With Selection.Border
  62.         .Weight = xlHairline
  63.         .LineStyle = xlAutomatic
  64.     End With
  65.     With Selection
  66.         .MajorTickMark = xlOutside
  67.         .MinorTickMark = xlNone
  68.         .TickLabelPosition = xlNextToAxis
  69.     End With
  70.     ActiveChart.PlotArea.Select
  71.     ActiveChart.Axes(xlValue).Select
  72.     With ActiveChart.Axes(xlValue)
  73.         .MinimumScaleIsAuto = True
  74.         .MaximumScaleIsAuto = True
  75.         .MinorUnitIsAuto = True
  76.         .MajorUnitIsAuto = True
  77.         .Crosses = xlAutomatic
  78.         .ReversePlotOrder = False
  79.         .ScaleType = xlLinear
  80.         .DisplayUnit = xlNone
  81.     End With
  82.     ActiveChart.Axes(xlCategory).Select
  83.     With ActiveChart.Axes(xlCategory)
  84.         .CrossesAt = 1
  85.         .TickLabelSpacing = 7
  86.         .TickMarkSpacing = 1
  87.         .AxisBetweenCategories = False
  88.         .ReversePlotOrder = False
  89.     End With
  90.     ActiveChart.ChartArea.Select
  91.     ActiveChart.Axes(xlCategory).Select
  92.     With Selection.Border
  93.         .Weight = xlHairline
  94.         .LineStyle = xlAutomatic
  95.     End With
  96.     With Selection
  97.         .MajorTickMark = xlOutside
  98.         .MinorTickMark = xlInside
  99.         .TickLabelPosition = xlNextToAxis
  100.     End With
  101.     With Selection.Border
  102.         .Weight = xlHairline
  103.         .LineStyle = xlAutomatic
  104.     End With
  105.     With Selection
  106.         .MajorTickMark = xlOutside
  107.         .MinorTickMark = xlNone
  108.         .TickLabelPosition = xlNextToAxis
  109.     End With
  110.     ActiveWindow.Visible = False
  111.     Windows("AAA-h.xls").Activate
  112.     Range("I32").Select
  113. End Sub

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多