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

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

¦^´_ 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

¦^´_ 30# c_c_lai
c_c_lai ¤j­ô  ¹ï¤£°_ÁÙ没§¹¦¨³Ì²×¥Ø¼Ð,¥i¥H¬Ý¬Ý¦A²{¦b¶Çµ¹§AÀɮ׬O§Ú­n¥Îvba»yªk§¹¦¨ªº³Ì²×¥Ø¼Ð¾ã­Ó¹Lµ{¦p¤U敍­z
  1 ¥ýªì©l¤ÀªRµ²ªGªí  
   2  ¦A°õ¦æoutline§P§O  , ¦pªG¦X®æ´N°O¿ý"ok"¤£¦X®æ´N°O¿ý"ng"  
   3  ¦pªG¦³"ng"­È¥h°£"ng"¸Ó¦C,  §â"ok"¦Ccopy ¨ì¤U¤@¦¸ªí®æ°Ï¶¡¦A°õ¦æoutline§P§O,(¦]¬°¦C¼Æ(®a¼Æ)´î¤Ö,§P§O­È·|§ïÅÜ)
  4  ¤@ª½¨ì¥þ³¡³£"ok"®É³o­Óªí®æ°Ï¶¡¬O§Ú¹Ïªí¸ê®Æªº¨Ó·½5 ³Ì«á¦A¼W¥[¤@ªí®æ°Ï¶¡(ºÙ¬°°õ¦æz_score)§â¥þ³¡¦C¼Æ(®a¼Æ)copy ¨ì³Ì«áªí®æ°Ï¶¡ (°õ¦æz_score)§@z_score§P§O
5 ¦A§¹¦¨³ø§i®Ñ
    11C1.rar (47.98 KB)

TOP

¦^´_ 30# c_c_lai
c_c_lai¤j­ô¥[¤J¤U¦C®É

   . SeriesCollection(1).XValues = Range(Sh.Name & "!$A$" & CStr(StartKBarRow) & ":" & Sh.Name & "!$A$" & CStr(EndKBarRow))
·|¥X²{"°õ¦æ¶¥¬q¿ù»~'1004'range¤èªk('global'ª«¥ó¥¢±Ñ)

TOP

¦^´_ 30# c_c_lai
c_c_lai ¤j­ô, ­ì½Ì§Úªº°g½k.§Ú§âDim StartKBarRow, EndKBarRow As Long±q»s¹Ïµ{¦¡²¾°£«áµ{¦¡´N¯à¥¿½T°õ¦æ

TOP

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

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

TOP

c_c_lai  ¤j­ô, ½Ð°Ý¦Cªí²Ä¤T­¶¥H«á³£¤£¨£¤F,­n¦p¦ó¥s¥X

TOP

¦^´_ 28# c_c_lai
c_c_lai ¤j­ô   ½Ð°Ý¦p¦ó³]©wÅý¹Ïªí°Ï»Pø¹Ï°Ï©³³¡ªÅ¶¡¤j¤@ÂI,§Ú¥[¤J¤ô¥­¶b¼ÐÃD®É³£·|»PÃþ§O¼ÐÅÒ­«疉

TOP

        ÀR«ä¦Û¦b : ¸Ü¦h¤£¦p¸Ü¤Ö¡A¸Ü¤Ö¤£¦p¸Ü¦n¡C
ªð¦^¦Cªí ¤W¤@¥DÃD