ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

½Ð¦U¦ì¤j¤jÀ°¦£­×§ï«Ø¥ß®r¤J¹Ïªí¿ù»~»yªk

¦^´_ 17# lamihsuen
  1.             ' ±N³Ì«á¤@¦¸²Ä¤@¦C(¤½¦¡)¼ÐÃD¦C¼ÐÃD»P²Ä¤G¦C¤½¦¡­È copy ¦Ü ZSCORE ªí®æ²Ä¤@¦C»P²Ä¤G¦C
  2.             z_oi = angin_sr
  3.             z_ai = z_sr
  4.             z_aj = 1
  5.             For z_oj = 1 To 12
  6.                 .Cells(z_ai - 4, z_aj).Value = .Cells(z_oi - 4, z_oj).Value
  7.                 .Cells(z_ai - 3, z_aj).Value = .Cells(z_oi - 3, z_oj).Value
  8.                 z_aj = z_aj + 1
  9.             Next z_oj
  10.             ' ©w¸q²Ä¥|¦Cªí®æ¼ÐÃD¦C
  11.             xlRow = .Range("B" & z_sr).End(xlDown).Row
  12.             .Cells((z_sr - 1), 1).Value = .Cells((sr - 1), 1).Value
  13.             .Cells((z_sr - 1), 2).Value = .Cells((sr - 1), 2).Value
  14.             .Cells((z_sr - 1), 3).Value = .Cells((sr - 1), 3).Value
  15.             .Cells((z_sr - 1), 4).Value = "§P§Oµ²ªG"
  16.             .Cells((z_sr - 1), 5).Value = "¤ÀªR¤èªk"
  17.             .Cells((z_sr - 1), 6).Value = "¨Ï¥Î»ö¾¹"
  18.                                                          
  19.             ' ¥»¦¸ "C" Äæ Z-SCORE ­È­pºâ
  20.             ' .Range("C" & z_sr & " :C" & xlRow).Formula = "=(b" & z_sr & "-$B$" & z_sr - 3 & ") /$C$" & z_sr - 3
  21.             ' .Range("D" & z_sr & " :D" & xlRow).Formula = "=IF(C" & z_sr & ">=3,""²§±`"",IF( C" & z_sr & "<=2,""ok"",""¦³½èºÃ""))"
  22.          
  23.             ' 2012/7/20 ·s¼W¦C
  24.             ' §P§O¥»¦¸ "C" Äæ Z-SCORE ­È¦pªG¬O outline «h z ­ÈÅã¥Ü "*"
  25.             ' ³]©w mue_sr, mue_oi ¬° z ­ÈÄæ¦ì­p¼Æ¾¹
  26.             mue_sr = z_sr
  27.             mue_oi = angin_sr
  28.             For mue_sr = mue_sr To xlRow
  29.                 If .Cells(mue_sr, 1) = .Cells(mue_oi, 1) Then
  30.                     .Cells(mue_sr, 3).Formula = "=(b" & mue_sr & "-$B$" & z_sr - 3 & ") /$C$" & z_sr - 3
  31.                     If .Cells(mue_sr, 3).Value > 3 Or .Cells(mue_sr, 3).Value <= -3 Then
  32.                         .Cells(mue_sr, 3).Font.Color = RGB(255, 0, 255)
  33.                     End If
  34.                     mue_oi = mue_oi + 1
  35.                 Else
  36.                     .Cells(mue_sr, 3).Value = "*"
  37.                     .Cells(mue_sr, 3).Interior.Color = RGB(255, 0, 0)
  38.                     .Cells(mue_sr, 3).HorizontalAlignment = xlHAlignCenter
  39.                 End If
  40.             Next mue_sr
  41.             '  ©w¸q z ­È§P§Oµ²ªG¨ÃÅã¥Ü (D) Äæ,"(Z) ­È <= 2 ¬° "OK" Åã¥Üºñ¦â","2<(Z) ­È <3 ¬° "¦³½èºÃ" Åã¥Ü¶À¦â,(Z)­È >3 ¬° "²§±`" Åã¥Ü¬õ¦â
  42.         End With
  43.             
  44.         '  Ã¸»s²Î­p¤ÀªR¹Ïªí
  45.         Call DrawStatistics(wr)
  46.     Next wr
  47. End Sub

  48. Sub DrawStatistics(ct As Integer)
  49.     Dim tbl As String
  50.     Dim totalRow As Long
  51.     Dim StartKBarRow, EndKBarRow As Long

  52.     StartKBarRow = 6
  53.     With Worksheets(ct)
  54.         tbl = .Name
  55.         EndKBarRow = .Range("A1").CurrentRegion.Rows.Count
  56.         Set Chart_Source = Range(tbl & "!$C$" & CStr(StartKBarRow) & ":" & tbl & "!$C$" & CStr(EndKBarRow))
  57.         
  58.         ' sPos(1) = CInt(Mid("205*090*090*100*132*096*132*090*173*090*314*090", (ct - 4) * 4 + 1, 3)) ' ¹Ï¼Ð®y¼Ð(¦C)
  59.         ' ¬°¦Ò¶q¦b¹ê°È¹B¥Î¤W¡A¨C±iªí³æ¤º§t¸ê®Æ¤º®e¤§¦h¹è¤£¤@¡A¥i¯à¹ê»Ú¨Ï¥Î¦C¼Æ®É¦³¼W´î¡A¬G§ï¥H°ÊºA³B²z¡C
  60.         sPos(1) = .UsedRange.Rows.Count
  61.         While IsEmpty(.Cells(sPos(1), 3).Value) And sPos(1) > 6       ' ©|¶·¦A¦¸¹LÂo³¡¤ÀªÅ¥Õ»P«D¯u¹ê¶×¤J¸ê®Æªº°ÝÃD¦C
  62.             sPos(1) = sPos(1) - 1
  63.         Wend
  64.         sPos(1) = sPos(1) + 5
  65.         
  66.         sPos(2) = CInt(Mid("001*001*001*001*001*001*001*001*001*001*001*001", (ct - 4) * 4 + 1, 3))   ' ¹Ï¼Ð®y¼Ð(Äæ)
  67.         sPos(3) = CInt(Mid("900*900*900*900*900*900*900*900*900*900*900*900", (ct - 4) * 4 + 1, 3))   ' ¹Ïªí¼e«×
  68.         sPos(4) = CInt(Mid("320*320*320*320*320*320*320*320*320*320*320*320", (ct - 4) * 4 + 1, 3))   ' ¹Ïªí°ª«×
  69.         xText = UCase(tbl) & " : Z - Score"
  70.         »s¹Ïµ{§Ç xlSh:=tbl
  71.     End With
  72. End Sub

  73. Private Sub »s¹Ïµ{§Ç(xlSh As String)                                ' ¥þ³¡­«Ã¸
  74.     Dim Sh As Worksheet, xi As Integer
  75.    
  76.     Set Sh = Sheets(xlSh)
  77.     Sh.ChartObjects.Delete

  78.     With Sh.ChartObjects.Add(Sh.Cells(sPos(1), sPos(2)).Left, Sh.Cells(sPos(1), sPos(2)).Top, sPos(3), sPos(4)).Chart
  79.         .ChartType = xlColumnClustered                          ' xlColumnStacked -> °ïÅ|ª½±ø¹Ï
  80.         .SetSourceData Source:=Chart_Source
  81.         .HasLegend = 0                                          ' ¹Ïªíªº¹Ï¨Ò:  ¤£¥i¨£
  82.         .SeriesCollection(1).AxisGroup = 1
  83.             
  84.         With .Axes(xlCategory)                                  ' X®y¼Ð¶b
  85.             .CategoryType = xlCategoryScale
  86.             ' .TickLabels.NumberFormatLocal = "hh:mm"
  87.             .MajorTickMark = xlNone
  88.             .Border.Weight = xlHairline
  89.             .Border.LineStyle = xlNone
  90.             .TickLabelPosition = xlLow
  91.             .TickLabels.Font.Size = 10
  92.         End With
  93.                   
  94.             '*******************************************************************
  95.                   
  96.         With .SeriesCollection(1)
  97.             .Shadow = False                                ' ¹Ïªí¤¤ªº¼Æ¦C(1)
  98.             .InvertIfNegative = True
  99.             ' .InvertColor = RGB(255, 124, 128)                      ' ·íªí¦C¼Æ­È¬°­t­È®É¡A±N¨äÅã¥Ü¤§ÃC¦â§óÅܦ¨²L¤ÑÂŦâ
  100.             .InvertColor = RGB(32, 178, 208)                         ' ·íªí¦C¼Æ­È¬°­t­È®É¡A±N¨äÅã¥Ü¤§ÃC¦â§óÅܦ¨«CÂŦâ
  101.         
  102.             With .Format.Fill
  103.                 .Visible = msoTrue
  104.                 ' .ForeColor.RGB = RGB(149, 179, 215)                ' ·íªí¦C¼Æ­È¬°¥¿­È®É¡AÅã¥Ü¤§ÃC¦â¬°¾ï¬õ¦â
  105.                 .ForeColor.RGB = RGB(255, 69, 0)                     ' ·íªí¦C¼Æ­È¬°¥¿­È®É¡AÅã¥Ü¤§ÃC¦â¬°¯»¬õ¦â
  106.                 .Transparency = 0
  107.                 .Solid
  108.             End With
  109.         
  110.             With .Border
  111.                 .Weight = xlHairline
  112.                 .LineStyle = xlNone
  113.             End With
  114.         
  115.             .HasDataLabels = True
  116.             .DataLabels.NumberFormat = "##.##"
  117.             .DataLabels.Position = xlLabelPositionOutsideEnd
  118.             ' With .Interior
  119.             '     .ColorIndex = 5
  120.             '     .PatternColorIndex = 42
  121.             '     .Pattern = xlSolid
  122.             ' End With
  123.         End With
  124.                   
  125.         ' *******************************************************************
  126.                      
  127.         With .Axes(xlValue).TickLabels.Font                    ' Y®y¼Ð¶b¤W¨è«×ªº¨è«×¼ÐÅÒªº¦rÅé
  128.             .FontStyle = "¼Ð·Ç"
  129.             .Size = 10
  130.         End With
  131.                      
  132.         With .Axes(xlValue)
  133.             .MajorUnit = 2                                     ' ¹Ïªí¥ª°¼¼Æ¦C¤§¶¡¶Z­È³]©w
  134.             ' .MaximumScale = 30
  135.             ' .MinimumScale = -40
  136.         End With
  137.         
  138.         .HasTitle = True                                       ' ¹Ïªíªº¼ÐÃD   ¥i¨£
  139.               
  140.         With .ChartTitle                                       ' ¹Ïªíªº¼ÐÃD
  141.             .Top = 1
  142.             .Text = xText
  143.             .Font.Size = 16
  144.         End With

  145.         With .PlotArea                                         ' ¹ÏªíªºÃ¸¹Ï°Ï
  146.             .Top = 16
  147.             .Left = 1
  148.             .Width = sPos(3)
  149.             .Height = sPos(4)
  150.             .Interior.ColorIndex = xlNone
  151.         End With
  152.     End With
  153. End Sub
½Æ»s¥N½X

TOP

¦^´_ 20# lamihsuen
½Ð±N drawStatistics() ¾ã­Ó©â´«±¼¡G
  1. Sub DrawStatistics(ct As Integer)
  2.     Dim tbl As String
  3.     Dim totalRow As Long
  4.     Dim StartKBarRow, EndKBarRow As Long

  5.     ' StartKBarRow = 6
  6.     With Worksheets(ct)
  7.         tbl = .Name
  8.         ' sPos(1) = CInt(Mid("205*090*090*100*132*096*132*090*173*090*314*090", (ct - 4) * 4 + 1, 3)) ' ¹Ï¼Ð®y¼Ð(¦C)
  9.         ' ¬°¦Ò¶q¦b¹ê°È¹B¥Î¤W¡A¨C±iªí³æ¤º§t¸ê®Æ¤º®e¤§¦h¹è¤£¤@¡A¥i¯à¹ê»Ú¨Ï¥Î¦C¼Æ®É¦³¼W´î¡A¬G§ï¥H°ÊºA³B²z¡C
  10.         sPos(1) = .UsedRange.Rows.Count                               ' ¥H c ¬°¨Ò¡AÁ`¦@¨Ï¥Î(¿é¤J)¤F 204 Rows ¸ê®Æ¿ý¡C
  11.         While IsEmpty(.Cells(sPos(1), 3).Value) And sPos(1) > 6       ' ©|¶·¦A¦¸¹LÂo³¡¤ÀªÅ¥Õ»P«D¯u¹ê¶×¤J¸ê®Æªº°ÝÃD¦C
  12.             sPos(1) = sPos(1) - 1
  13.         Wend
  14.         
  15.         ' EndKBarRow = .Range("A1").CurrentRegion.Rows.Count   ' ¥H c ¬°¨Ò¡A§PÂ_A1:A51°Ï¶¡¹ê»Ú¨Ï¥Î¤F(¦@¦³)¦h¤Ö¦C(Rows)
  16.         ' ¥H c ¬°¨Ò¡AA155:A204 ¶¡Á`¦@¨Ï¥Î¤F¦h¤Ö¦C(50)¡C±µµÛ¦A¨D¥X¤W¤@­Ó°Ï¶¡ªº³Ì«á¤@¦æªº©Ò¦b¦æ¼Æ (204-50-2(ªÅ¥Õ¦C)=152)¡C
  17.         EndKBarRow = sPos(1) - .Range("A" & sPos(1)).CurrentRegion.Rows.Count - 2
  18.         ' ¥H c ¬°¨Ò¡A A105:A152 ¶¡Á`¦@¨Ï¥Î¤F¦h¤Ö¦C(48)¡C±µµÛ¦A¨D¥X¥»°Ï¶¡ªº²Ä¤@¦æªº©Ò¦b¦æ¼Æ (152-48+5(¼ÐÃD¦C)=109)¡C
  19.         StartKBarRow = EndKBarRow - .Range("A" & EndKBarRow).CurrentRegion.Rows.Count + 5
  20.         If (StartKBarRow < 6) Then StartKBarRow = 6          ' < 6 «h¥[ 1¡A ¦]°_©l¦C³Ì¤Ö¬° 6¡C
  21.         
  22.         Set Chart_Source = Range(tbl & "!$C$" & CStr(StartKBarRow) & ":" & tbl & "!$C$" & CStr(EndKBarRow))
  23.         
  24.         sPos(1) = sPos(1) + 5                                                                         ' ¹Ï¼Ð®y¼Ð(¦C)
  25.         sPos(2) = CInt(Mid("001*001*001*001*001*001*001*001*001*001*001*001", (ct - 4) * 4 + 1, 3))   ' ¹Ï¼Ð®y¼Ð(Äæ)
  26.         sPos(3) = CInt(Mid("900*900*900*900*900*900*900*900*900*900*900*900", (ct - 4) * 4 + 1, 3))   ' ¹Ïªí¼e«×
  27.         sPos(4) = CInt(Mid("320*320*320*320*320*320*320*320*320*320*320*320", (ct - 4) * 4 + 1, 3))   ' ¹Ïªí°ª«×
  28.         xText = UCase(tbl) & " : Z - Score"
  29.         »s¹Ïµ{§Ç xlSh:=tbl
  30.     End With
  31. End Sub
½Æ»s¥N½X
±ß¦w¡I

TOP

¦^´_ 20# lamihsuen
Sub DrawStatistics(ct As Integer)
    Dim tbl As String
    Dim totalRow As Long
    Dim StartKBarRow, EndKBarRow As Long

    ' StartKBarRow = 6
    With Worksheets(ct)
        tbl = .Name
        ' sPos(1) = CInt(Mid("205*090*090*100*132*096*132*090*173*090*314*090", (ct - 4) * 4 + 1, 3)) ' ¹Ï¼Ð®y¼Ð(¦C)
        ' ¬°¦Ò¶q¦b¹ê°È¹B¥Î¤W¡A¨C±iªí³æ¤º§t¸ê®Æ¤º®e¤§¦h¹è¤£¤@¡A¥i¯à¹ê»Ú¨Ï¥Î¦C¼Æ®É¦³¼W´î¡A¬G§ï¥H°ÊºA³B²z¡C
        sPos(1) = .UsedRange.Rows.Count                               ' ¥H c ¬°¨Ò¡AÁ`¦@¨Ï¥Î(¿é¤J)¤F 204 Rows ¸ê®Æ¿ý¡C
        While IsEmpty(.Cells(sPos(1), 3).Value) And sPos(1) > 6       ' ©|¶·¦A¦¸¹LÂo³¡¤ÀªÅ¥Õ»P«D¯u¹ê¶×¤J¸ê®Æªº°ÝÃD¦C
            sPos(1) = sPos(1) - 1
        Wend
        
        ' EndKBarRow = .Range("A1").CurrentRegion.Rows.Count   ' ¥H c ¬°¨Ò¡A§PÂ_A1:A51°Ï¶¡¹ê»Ú¨Ï¥Î¤F(¦@¦³)¦h¤Ö¦C(Rows)
        ' ¥H c ¬°¨Ò¡AA155:A204 ¶¡Á`¦@¨Ï¥Î¤F¦h¤Ö¦C(50)¡C±µµÛ¦A¨D¥X¤W¤@­Ó°Ï¶¡ªº³Ì«á¤@¦æªº©Ò¦b¦æ¼Æ (204-50-2(ªÅ¥Õ¦C)=152)¡C
        EndKBarRow = sPos(1) - .Range("A" & sPos(1)).CurrentRegion.Rows.Count - 2
        ' ¥H c ¬°¨Ò¡A A105:A152 ¶¡Á`¦@¨Ï¥Î¤F¦h¤Ö¦C(48)¡C±µµÛ¦A¨D¥X¥»°Ï¶¡ªº²Ä¤@¦æªº©Ò¦b¦æ¼Æ (152-48+5(¼ÐÃD¦C)=109)¡C
        StartKBarRow = EndKBarRow - .Range("A" & EndKBarRow).CurrentRegion.Rows.Count + 5
        If (StartKBarRow < 6) Then StartKBarRow = 6          ' < 6 «h¥[ 1¡A ¦]°_©l¦C³Ì¤Ö¬° 6¡C
        
        Set Chart_Source = Range(tbl & "!$C$" & CStr(StartKBarRow) & ":" & tbl & "!$C$" & CStr(EndKBarRow))
        
        sPos(1) = sPos(1) + 5                                                                         ' ¹Ï¼Ð®y¼Ð(¦C)
        sPos(2) = CInt(Mid("001*001*001*001*001*001*001*001*001*001*001*001", (ct - 4) * 4 + 1, 3))   ' ¹Ï¼Ð®y¼Ð(Äæ)
        sPos(3) = CInt(Mid("900*900*900*900*900*900*900*900*900*900*900*900", (ct - 4) * 4 + 1, 3))   ' ¹Ïªí¼e«×
        sPos(4) = CInt(Mid("320*320*320*320*320*320*320*320*320*320*320*320", (ct - 4) * 4 + 1, 3))   ' ¹Ïªí°ª«×
        xText = UCase(tbl) & " : Z - Score"
        »s¹Ïµ{§Ç xlSh:=tbl
    End With
End Sub

TOP

½×¾Âºô­¶¸ê®Æ¬O§_¦³²§ª¬¡H

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2012-7-22 08:01 ½s¿è

2012/7/22 ¥[¤J XValues ³]©w¹Ïªí¼Æ¦C¤¤ X ­Èªº°}¦C¡C ½Ð±N "»s¹Ïµ{§Ç()" ¤¤ .AxisGroup = 1 ªº¤U¤@¦C¼W¥[¤@¦æ¡G
.SeriesCollection(1).XValues = Range(Sh.Name & "!$A$" & CStr(StartKBarRow) & ":" & Sh.Name & "!$A$" & CStr(EndKBarRow))
¦p¤U©Ò¥Ü¡G


Private Sub »s¹Ïµ{§Ç(xlSh As String)                                ' ¥þ³¡­«Ã¸
    Dim Sh As Worksheet, xi As Integer
   
    Set Sh = Sheets(xlSh)
    Sh.ChartObjects.Delete

    With Sh.ChartObjects.Add(Sh.Cells(sPos(1), sPos(2)).Left, Sh.Cells(sPos(1), sPos(2)).Top, sPos(3), sPos(4)).Chart
        .ChartType = xlColumnClustered                            ' xlColumnStacked -> °ïÅ|ª½±ø¹Ï
        .SetSourceData Source:=Chart_Source
        .HasLegend = 0                                                           ' ¹Ïªíªº¹Ï¨Ò:  ¤£¥i¨£
        .SeriesCollection(1).AxisGroup = 1
        ' 2012/7/22 ¥[¤J XValues ³]©w¹Ïªí¼Æ¦C¤¤ X ­Èªº°}¦C¡C ­ì¥»¥¼³]©w¬O¥H¼Æ¦C§Ç¸¹³B²z¡A¬G¤©¥H­×¥¿¥H²Å¨Æ¹ê¡C
        .SeriesCollection(1).XValues = Range(Sh.Name & "!$A$" & CStr(StartKBarRow) & ":" & Sh.Name & "!$A$" & CStr(EndKBarRow))


¦P®É±N StartKBarRow »P EndKBarRow ªºÅܼƫŧi±q DrawStatistics() ¤¤²¾¸m¤½¥ÎÅܼƫŧi°Ï¶ô¡C


Option Explicit

Dim sPos(1 To 4)
Dim xText As String
Dim Chart_Source As Variant
' ¦]©ó DrawStatistics() ¥H¤Î »s¹Ïµ{§Ç() ¨ç¦¡¤º§¡»Ý¨Ï¥Î¡A¬G±N¦¹¨âÅܼƧאּ¤½¥ÎÅܼÆ
Dim StartKBarRow, EndKBarRow As Long   

¨ì¦¹§Ú·QÀ³¸Ó·~¤w¤j¥\§i¦¨¤F§a¡A¯¬©p¾Ç·~²r¶i¡I

P.S. ³Ì«á¦AÃØ°e¤@­Ó¤p§ª« ("##.##" §ï¦¨¦p¤U¡A¾\Äý·|§ó©ú½T)¡G
.DataLabels.NumberFormat = "#0.##"

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2012-7-24 21:06 ½s¿è

¦^´_ 8# lamihsuen
ºô­¶¦n¹³¦³°ÝÃD¡A¦³ªº¤º®e®Ú¥»¬Ý¤£¨ì°T®§¡A

TOP

¦^´_ 30# lamihsuen
­ì¥»¬°
  1.         With .PlotArea                                         ' ¹ÏªíªºÃ¸¹Ï°Ï
  2.             .Top = 16
  3.             .Left = 1
  4.             .Width = sPos(3)
  5.             .Height = sPos(4)
  6.             .Interior.ColorIndex = xlNone
  7.         End With
½Æ»s¥N½X
­×¥¿¬°
  1.         With .PlotArea                                         ' ¹ÏªíªºÃ¸¹Ï°Ï
  2.             .Top = 16
  3.             .Left = 1
  4.             .Width = sPos(3)
  5.             .Height = sPos(4)
  6.             .Interior.ColorIndex = xlNone
  7.             
  8.             ' ¥i¨Ì­Ó¤H¤§¦Ò¶q¤©¥H¼W´î¤º³¡¹Ïªíªº°ª¡B§C¡B¥H¤Î¼e«×
  9.             .InsideLeft = 40
  10.             .InsideTop = Sheets(xlSh).Rows(3).RowHeight * 2
  11.             .InsideWidth = sPos(3) - 50
  12.             .InsideHeight = sPos(4) - 5 * Sheets(xlSh).Rows(3).RowHeight
  13.         End With
½Æ»s¥N½X
¸Õ¸Õ¬Ý¡I

TOP

¦^´_ 30# lamihsuen
­è¶Çªº«ç»ò¤S¤£¨£¤F¡H¡H¡H¡H¡H¡H

TOP

¥»ÃD¥Ø¦]ºô­¶¦³¨Ç©Ç²§(²Ä¤T­¶¦³¨Ç¦^À³³£¦Û°Ê®ø¥¢µL¼v)¡A¥B°ÝÃD·~¤w¥t¦æ¸Ñ¨M¡C
À³¤©¥Hµ²®×¡C

TOP

        ÀR«ä¦Û¦b : ºÉ¦h¤Ö¥»¥÷¡A´N±o¦h¤Ö¥»¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD