| ©«¤l2035 ¥DÃD24 ºëµØ0 ¿n¤À2031 ÂI¦W0  §@·~¨t²ÎWin7 ³nÅ骩¥»Office2010 ¾\ŪÅv100 ©Ê§O¨k µù¥U®É¶¡2012-3-22 ³Ì«áµn¿ý2024-2-1 
 | 
                
| ¥»©«³Ì«á¥Ñ c_c_lai ©ó 2012-5-7 14:42 ½s¿è 
 ¦^´_ 3# white5168
 ½Æ»s¥N½XOption Explicit
Sub drawCharts()
    Dim totalRows As Single
    Dim xRow, yCol, cHeight, cWidth As Integer
    Dim text As String
    Dim chartname As String
    Dim sRowHeight As Single
    
    xRow = 3
    yCol = 1
    cHeight = 31         'CHeight ©w¸q¬°¹Ïªí©Ò¦ûªº¦C°ª
    cWidth = 874
        
    Sheets("¤u§@ªí1").Select
    
    ActiveSheet.ChartObjects.Delete
        
    totalRows = Sheets("¤u§@ªí1").Range("B" & Rows.Count).End(xlUp).Row     ' ¶Ç¦^ B Äæ©Ò¨Ï¥ÎÀx¦s®æ¤§³Ì«á¤@®æ¤§¦C¸¹
    '¥ý§â¦C°ª§ä¥X¨Ó, ¤~¦nºâ¥X¹Ïn¦û´X¦C, ¨âӹϤ~¦n³s¦b¤@°_
    sRowHeight = Sheets("¤u§@ªí1").Rows(3).RowHeight
    
    ActiveSheet.Shapes.AddChart.Select
    With ActiveChart
        .SetSourceData Source:=Range("¤u§@ªí1!$B$1:¤u§@ªí1!$B$" & totalRows & ", ¤u§@ªí1!$C$1:¤u§@ªí1!$F$" & totalRows)
        .ChartType = xlStockOHLC
        With .ChartGroups(1)
             .AxisGroup = 1
             ' .UpBars.Format.Fill.ForeColor.RGB = RGB(255, 0, 0)           ' ¬õ¦â
             .UpBars.Format.Fill.ForeColor.RGB = RGB(255, 69, 0)          ' ¾ï¬õ¦â
             ' .DownBars.Format.Fill.ForeColor.RGB = RGB(0, 32, 96)       ' ²`ÂŦâ
             .DownBars.Format.Fill.ForeColor.RGB = RGB(0, 250, 170)     ' ²L¬vºñ¦â
        End With
        
        .SeriesCollection.Add Source:=Range("¤u§@ªí1!$G$2:¤u§@ªí1!$I$" & totalRows)
        
        With .SeriesCollection(5)
            .AxisGroup = 2
            .Name = "=¤u§@ªí1!$G$1"
            .ChartType = xlColumnClustered
            
            With .Format.Line
                .Visible = msoTrue          ' ¦¨¥æ¶q
                .ForeColor.RGB = RGB(147, 112, 219)        ' ¦¨¥æ¶q«ü¼ÆÅã¥Ü¤§ÃC¦â    ---   µµ¦â
                .Transparency = 0
            End With
        End With
        
        With .SeriesCollection(6)
            .Name = "=¤u§@ªí1!$H$1"
            .ChartType = xlLine
            With .Format.Line
                .Visible = msoTrue          ' ¥D¤O¬É¤J
                ' .ForeColor.RGB = RGB(105, 205, 170)      ' ¥D¤O¬É¤J«ü¼ÆÅã¥Ü¤§ÃC¦â    ---   Âźñ¦â
                .ForeColor.RGB = RGB(32, 178, 170)         ' ¥D¤O¬É¤J«ü¼ÆÅã¥Ü¤§ÃC¦â    ---   ®ü¬vºñ¦â
                .Transparency = 0
            End With
        End With
        
        With .SeriesCollection(7)
            .Name = "=¤u§@ªí1!$I$1"
            .ChartType = xlLine
            With .Format.Line
                .Visible = msoTrue          ' ´²¤á¤è¦V
                .ForeColor.RGB = RGB(65, 105, 225)         ' ´²¤á¤è¦V«ü¼ÆÅã¥Ü¤§ÃC¦â    ---   ¤ÑÂŦâ
                .Transparency = 0
            End With
        End With
        
        .Axes(xlValue).TickLabels.NumberFormatLocal = "0_ "
        
        With .Axes(xlCategory)                            ' X®y¼Ð¶b (®É¶¡¶b)
            .CategoryType = xlCategoryScale
            .TickLabels.NumberFormatLocal = "hh:mm"
            .MajorTickMark = xlNone
            .Border.Weight = xlHairline
            .Border.LineStyle = xlNone
            .TickLabelPosition = xlLow
            .TickLabels.Font.Size = 10
        End With
        
        .ChartArea.Height = cHeight * sRowHeight                           ' ±N쥻³]©w¤§°ª«×½Õ¦Ü¾A«×¦ì¸m
        .ChartArea.Width = cWidth
        
        text = "ªÑ²¼¹Ï K ½u¡B¥D¤O¡B´²¤á¡B»P¦¨¥æ¶q"
        
        .SetElement (msoElementChartTitleCenteredOverlay)
        .ChartTitle.text = text
        .ChartTitle.Format.TextFrame2.TextRange.Font.Size = 14
        .Legend.Position = xlCorner                         ' ±N¹Ïªí¹Ï¥Ü±q¹Ïªí³Ì¤U¤è½Õ¾ã¨ì¹Ïªí¤§¥k¤W¨¤¦ì¸m
    End With
    
    chartname = Trim(Replace(ActiveChart.Name, ActiveSheet.Name, ""))
    ActiveSheet.Shapes(chartname).Left = Cells(xRow, yCol).Left     ' ³]©w¦¹¹Ïªí¹ê»ÚÂ\©ñªº X¡BY ®y¼Ð¦ì¸m¡C
    ActiveSheet.Shapes(chartname).Top = Cells(xRow, yCol).Top
    
    Range("A1").Select
End Sub
 | 
 |