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

[µo°Ý] ¥D®y¼Ð¶b»P°Æ®y¼Ð¶b¸s²Õ¶¡À³¦p¦ó¥¿½T³]©w

[µo°Ý] ¥D®y¼Ð¶b»P°Æ®y¼Ð¶b¸s²Õ¶¡À³¦p¦ó¥¿½T³]©w

½Ð±Ð¦U¦ì¥ý¶i¡G
¦b¹ÏªíÀ³¥Î¤W¡A¥D®y¼Ð¶b»P°Æ®y¼Ð¶b¸s²Õ¶¡À³¸Ó¦p¦ó¥h¥¿½T³]©w¡H
ªþ¤W°õ¦æ«e«á¤§µ²ªGµe­±¡C ¤§«e´¿¸gµo¥Í¹L¿ù»~°T®§¡A¦p¹Ïªí¤@¡C
§Ú¬O¨Ï¥Î¦P¤@¼Ò²Õ¤À§O°õ¦æ¦b Omega¡B²Î­p¹Ïªíªº¨â­Ó¤u§@ªí³æ¤º¡C
«á¨Ó¤£ª¾¬O§_¦b­×§ï¹Lµ{¤¤µL·NÁ×±¼¤F (½Ð°Ý¬O§_»yªk¤£¥¿½T¡HÀ³¸Ó¯d·N­þ¸Ì¡H)¡C
·í«eµo¥Íªº°ÝÃD¬O¡G
·í±z¿ï«öºØ·|©Ò¦³²Î­p¹Ïªí¡B©Î­«Ã¸Omega¡B§í©Î¬O­«Ã¸²Î­p¹Ïªíµ¥«ö¶s¡A
¤@¤Á³£¯à¥¿±`Åã¥Ü (¦p¹Ïªí¤G)¡A¦ý¬O·í±z¿ï«ö²Î­p¹ÏªíÂk¦ì¡A¦¨¥æ»ù«oÅܦ¨
¤@¾î½u¤F¡AÀˬdµ²ªG¬O¥¦·|¥h§ïÅÜ­ì¥ý¤§³]©w (¦¨¥æ»ù­ì³]©w¬°°Æ®y¼Ð¶b¸s²Õ¡A
¤@¸g°õ¦æÂk¬°«ö¶s¡A¸gÀˬd¥¦«o¦¨¬°¥D®y¼Ð¶b)¡A½Ð°Ý»yªk¤WÀ³¦p¦ó§ï¶i¡H
·q½Ð¦U¦ì«e½ú«üÂI¡AÁÂÁ±z¡I
¹Ïªí¤@¡G
01.png
2012-4-14 12:10

¹Ïªí¤G¡G
02.png
2012-4-14 11:59


ªþ¤WÀɮסG
¥D¤O¡B´²¤á»P»ù¶q.rar (175.82 KB)
01.png

¦^´_ 1# c_c_lai
ª©¥»¤£¹Ï ¤£©ö°»¿ù ,¼g­Ó½d¨Ò§A°Ñ¦Ò¤@¤U
  1. Private Sub »s¹Ï()
  2.     Dim xR As Range, Xi As Integer, i As Integer, ¹Ï¦â()
  3.     ¹Ï¦â = Array(4, 6, 8, 10)
  4.     ActiveSheet.ChartObjects.Delete         '§R°£¥þ³¡¹Ïªí
  5.     Set xR = Range("F1")    '§Q¥ÎxRªº¦ì¸m ³]¤U¹Ïªíªº¦ì¸m
  6.         '¥[¤J·s¹Ïªí  ¶·«ü©w 1¥kÃä¦ì¸m, 2°ª«×¦ì¸m, 3¹ÏªíªºWidth, 4¹ÏªíªºHeight
  7.         With ChartObjects.Add(xR.Left, xR.Top, xR.Resize(, 10).Width, xR.Resize(10).Height).Chart
  8.             .ChartType = 51  ' xlLineMarkers    '§é½u¹Ï                             '¹Ïªí ¦¡¼Ë
  9.             With ActiveSheet.Range("A11").CurrentRegion
  10.                     Set xR = Union(.Columns(1), .Columns(3), .Columns(5))
  11.                     '¸ê®Æ ½d³òªº 1,3,5 Ä欰¹Ïªí¸ê®Æ  :²Ä1Äæ ¬°x¶bªº¼Æ­È
  12.             End With
  13.             .SetSourceData Source:=xR, PlotBy:=xlColumns
  14.             '¹Ïªí¸ê®Æ¨Ó·½ : xR  ¸ê®Æ¦¡¼Ë: Äæ
  15.                           
  16.              .HasTitle = True                                              'Åã¥Ü ¹Ïªí¼ÐÃD
  17.              .ChartTitle.Characters.Text = ActiveSheet.Name                'HasTitle = False ·|¦³¿ù»~
  18.              .HasAxis(xlCategory, xlPrimary) = False                       '¤£Åã¥Ü X¶b®y¼Ð
  19.             
  20.             'HasLegend ¹Ï¨Ò
  21.              .HasLegend = False                                         ' ¨ú®ø Åã¥Ü ¹Ï¨Ò
  22.            '  .Legend.Position = xlTop                                   'Åã¥Ü ¹Ï¨Ò¦ì¸m
  23.            ' .Axes(xlCategory).TickLabels.NumberFormatLocal = "m/d;@"    ' Axes(xlCategory) X®y¼Ð¶b
  24.            ' ** ¤W¤G¦¡ ¶·  Åã¥Ü¹Ï¨Ò ->  .HasLegend = True
  25.             
  26.             '.SeriesCollection(1).AxisGroup = 2                           '·s¼W Y®y¼Ð¶b °Æ®y¼Ð¶b
  27.           '  .SeriesCollection(3)).Delete                 '§R°£²Ä3¼Æ¦C¸ê®Æ
  28.             With .Axes(xlValue)          'y¶b®æ½u
  29.                 .HasMajorGridlines = 0   '¨ú®ø ¥D®æ½u
  30.                 .HasMinorGridlines = 0   '¨ú®ø °Æ®æ½u
  31.             End With
  32.             '¥H¤U¤@¨Çµ{¦¡½X §A¥i¥Î¿ý»s±oª¾
  33.             With .ChartArea                                             '¹Ïªíªº¹Ïªí°Ï
  34.                 .Border.Weight = 1
  35.                 .Border.LineStyle = -1
  36.                 .Fill.OneColorGradient Style:=msoGradientHorizontal, Variant:=3, Degree:=0.231372549019608
  37.                 .Fill.Visible = True
  38.                 .Fill.ForeColor.SchemeColor = ¹Ï¦â(0)
  39.             End With
  40.             With .PlotArea                                              '¹Ïªíªº ø¹Ï°Ï
  41.                 .Fill.OneColorGradient Style:=msoGradientHorizontal, Variant:=1, _
  42.                 Degree:=0.231372549019608
  43.                 .Fill.Visible = True
  44.                 .Fill.ForeColor.SchemeColor = ¹Ï¦â(0)
  45.                 With .Border
  46.                     .ColorIndex = 16
  47.                     .Weight = xlThin
  48.                     .LineStyle = xlContinuous
  49.                 End With
  50.             End With
  51.             For i = 1 To .SeriesCollection.Count
  52.                 With .SeriesCollection(i)   '¼Æ¦C
  53.                   '  .XValues = ""           '<-¬°x¶bªº¼Æ­È   ¥i¦b¦¹¨ú®ø
  54.                     With .Border
  55.                         .ColorIndex = ¹Ï¦â(i)
  56.                         .Weight = xlMedium
  57.                         .LineStyle = xlContinuous
  58.                     End With
  59.                     '¥H¤UÄÝ©Ê ¥u¾A¦X §é½u¹Ï
  60.                    ' .MarkerBackgroundColorIndex = xlAutomatic
  61.                     '.MarkerForegroundColorIndex = xlAutomatic
  62.                     '.MarkerStyle = xlNone
  63.                     '.Smooth = False
  64.                     '.MarkerSize = 7
  65.                     '.Shadow = False
  66.                 End With
  67.             Next
  68.         End With
  69. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# GBKEE
ÁÂÁ±z§¹¾ãªº»¡©ú¡A¦ý¬O¦³­Ó­«­nªº¡B¤]¬O§Ú¥Ø«e¤£¬ÆÁA¸Ñªº³¡¤À¦p¤U¡A©|½Ð¦A¤©½ç±Ð¡G
                          .      
    Set xR = Range("F1")    '§Q¥ÎxRªº¦ì¸m ³]¤U¹Ïªíªº¦ì¸m
    '¥[¤J·s¹Ïªí  ¶·«ü©w 1¥kÃä¦ì¸m, 2°ª«×¦ì¸m, 3¹ÏªíªºWidth, 4¹ÏªíªºHeight
    With ChartObjects.Add(xR.Left, xR.Top, xR.Resize(, 10).Width, xR.Resize(10).Height).Chart
        .ChartType = 51  ' xlLineMarkers    '§é½u¹Ï                             '¹Ïªí ¦¡¼Ë
        With ActiveSheet.Range("A11").CurrentRegion
            Set xR = Union(.Columns(1), .Columns(3), .Columns(5))
            '¸ê®Æ ½d³òªº 1,3,5 Ä欰¹Ïªí¸ê®Æ  :²Ä1Äæ ¬°x¶bªº¼Æ­È
        End With
        .SetSourceData Source:=xR, PlotBy:=xlColumns
        '¹Ïªí¸ê®Æ¨Ó·½ : xR  ¸ê®Æ¦¡¼Ë: Äæ
                          .      
    End With

±z»¡²Ä1Äæ ¬°x¶bªº¼Æ­È¡A«üªº¬O¤U¦Cªº "=²Î­p¹Ïªí!$B$2:$B$" & totalRows ¡H °²³]¬Oªº¸Ü¡A ¨º»ò³o¨àªº "¸ê®Æ½d³òªº 1,3,5 Ä欰¹Ïªí¸ê®Æ"
§Y¬°°²³]ªº²Ä¤@Äæ¡B²Ä¤TÄæ¡B²Ä¤­Äæ¡A¦b¥Ø«eÀ³¦p¦ó¥h¹ïÀ³¨ì§Úªº ( F Äæ )¡B( I Äæ )¡B( J Äæ )¡B( V Äæ )µ¥¥|²Õ½u©O¡H §Ú¯à§_³o»ò³]©w
Set xR = Union(Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows), Range("²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows), Range("²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$I$" & totalRows), Range("²Î­p¹Ïªí!$J$1:²Î­p¹Ïªí!$J$" & totalRows), Range("²Î­p¹Ïªí!$V$1:²Î­p¹Ïªí!$V$" & totalRows))
¦]¬°¦pªG§Úª½±µ¨Ï¥Î­ì¥»ªº  .SetSourceData Source:=Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows & ", ²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows & ", ²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$J$" & totalRows)  
¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¦¨¥æ»ù¡B¥D¤O¬É¤J¡B¥H¤Î´²¤á¤è¦V¡A¦ý¬O²Ä¥|²Õªº ¦¨¥æ¶q «oµLªkÀ½¤J¡A§Ú¸Õ¹L³Ì¦h¥u¯à¨Ï¥Î¤T²Õ«Å§i¡C
¨ä¤¤²Ä¤@²Õ¬O®É¶¡¶b¼Æ­È¡B²Ä¤@²Õ¬O¦¨¥æ»ù¸ê®Æ¶b¼Æ­È¡B²Ä¤@²Õ¬O¥D¤O¬É¤J¡B´²¤á¤è¦V¸ê®Æ¶b¼Æ­È (¦]¦¹¨âÄæ«Y¬° I¡BJ¨âÄ椧­ì¦]¡A©Ò¥H¬O I1:J###)¡C
³o¥ç¬O§Ú·|¥[¤W«áÄò«Å§i¤§¬G¡G
   .SeriesCollection.Add Source:=Range("²Î­p¹Ïªí!$V$2:²Î­p¹Ïªí!$V$" & totalRows)  ' ¦¨¥æ¶q¸ê®Æ
   .SeriesCollection(4).Name = "=²Î­p¹Ïªí!$V$1"
©Ò¥H¦b¹ê°È¹B§@¤W¡A²Ä¤G­Ó¤u§@ªí³æ¤§¹Ïªí¤j³¡¤À®É¶¡§¡¯à¶¶§Q²£¥Í¡A¦ý±µµÛ¦b²£¥Í²Ä¤@­Ó¤u§@ªí³æ¤§¹Ïªí®É¡A¦]¬°»Ý¥h¹ïÀ³²Ä¤G­Ó¤u§@ªí³æ¤§¤w¡B©Î«Ý¶×¤J¸ê®Æ¡A
®É¦Ó¶¶ºZ¡B°¸®É«K¥Xª¬ªp¤F (¦p¥ý«eªþ¤Wªº¹Ïªí¤@¡B¤G)¡A ³o¬O²Ä¤@ºØ±¡§Î¡C

¦]¬°¦Ò¼{¦³®É¬°¤F¾\Äý¤è«K¦]¯À¡A¦³¥i¯à·|ÀH®É±N¹Ïªí²¾¦ì¤è«K¾\Äý¡A³Ì²×·|§Æ±æ¨t²Î¯à¦Û°Ê±N¹ÏªíÂk¦^­ì¨Ó³]©w¤§®y¼Ð¦ì¸m¡A¦¹µ{¦¡¬q(¹ÏªíÂk¦ì¶s - setRowColumn)«h§ó§ï¬°¡G
   ActiveChart.SetSourceData Source:=Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows & ", ²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows & ", ²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$J$" & totalRows)  ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¦¨¥æ»ù¡B¥D¤O¬É¤J¡B¥H¤Î´²¤á¤è¦V¡C
   ActiveChart.SeriesCollection.Add Source:=Range("²Î­p¹Ïªí!$V$2:²Î­p¹Ïªí!$V$" & totalRows)
   ActiveChart.SeriesCollection(4).Name = "=²Î­p¹Ïªí!$S$1"     ' S1 »P V1 ¬Û¦P¼ÐÃD¡A§¡¬° ¦¨¥æ¶q
²¾¦ì©ÎªÌ¬O·s¸ê®Æ¶×¤J®É¡A§¡·|³B²z¤W­±¤T¦æ°Ê§@¡Aµ²ªG¤£¬O¥X²{¥ý«eªþ¤Wªº¹Ïªí¤@ªº°ÝÃD¡A«K¬O¹Ïªí¤Gªº°ÝÃD¡C
¤£ª¾¬O§_¦b­×¥¿¼Ò¦¡¤U¤£¯à¨Ï¥Î ActiveChart.SeriesCollection.Add ¡H °²³]±ø¥ó¦¨¥ß¡A¨º­n¦p¦ó¶¶§Q±N²Ä¥|²Õ(¬Æ©Î¬OÁÙ¦³²Ä¤­²Õ...)¦w¥þ°e¤WÂS©O¡H

GBKEE«e½ú¡A¹ê¦b¬O¤£¦n·N«ä¡A³Â·Ð±z¤F¡I

¥H¤U¬O§ÚÄæ¦ì±qÄÝÃö«Y¹ïÀ³¤º®e¡A·q½Ð°Ñ¦Ò¡G     
                          .      
totalRows = Sheets("²Î­p¹Ïªí").Range("B" & Rows.Count).End(xlUp).Row     ' ¶Ç¦^ B Äæ©Ò¨Ï¥ÎÀx¦s®æ¤§³Ì«á¤@®æ¤§¦C¸¹
                          .     
                          .   
' ¿ï¨ú¸ê®Æ¨Ó·½->¦¨¥æ»ù      ( F Äæ )                                ----->  °Æ®y¼Ð¶b¸s²Õ
ActiveChart.SeriesCollection(1).Name = "=²Î­p¹Ïªí!$F$1"            
ActiveChart.SeriesCollection(1).Values = "=²Î­p¹Ïªí!$F$2:$F$" & totalRows      
ActiveChart.SeriesCollection(1).XValues = "=²Î­p¹Ïªí!$B$2:$B$" & totalRows  ' ®É¶¡¶b

' ¿ï¨ú¸ê®Æ¨Ó·½->¥D¤O¬É¤J    ( I Äæ )                                ----->  ¥D®y¼Ð¶b¸s²Õ   
ActiveChart.SeriesCollection(2).Name = "=²Î­p¹Ïªí!$I$1"            
ActiveChart.SeriesCollection(2).Values = "=²Î­p¹Ïªí!$I$2:$I$" & totalRows   
ActiveChart.SeriesCollection(2).XValues = "=²Î­p¹Ïªí!$B$2:$B$" & totalRows  ' ®É¶¡¶b     

' ¿ï¨ú¸ê®Æ¨Ó·½->´²¤á¤è¦V    ( J Äæ )                                ----->  ¥D®y¼Ð¶b¸s²Õ
ActiveChart.SeriesCollection(3).Name = "=²Î­p¹Ïªí!$J$1"            
ActiveChart.SeriesCollection(3).Values = "=²Î­p¹Ïªí!$J$2:$J$" & totalRows
ActiveChart.SeriesCollection(3).XValues = "=²Î­p¹Ïªí!$B$2:$B$" & totalRows  ' ®É¶¡¶b   

' ¿ï¨ú¸ê®Æ¨Ó·½->¦¨¥æ¶q      ( V Äæ )                                ----->  ¥D®y¼Ð¶b¸s²Õ
ActiveChart.SeriesCollection(4).Name = "=²Î­p¹Ïªí!$V$1"            
ActiveChart.SeriesCollection(4).Values = "=²Î­p¹Ïªí!$V$2:$V$" & totalRows   
ActiveChart.SeriesCollection(4).XValues = "=²Î­p¹Ïªí!$B$2:$B$" & totalRows  ' ®É¶¡¶b

TOP

¦^´_ 3# c_c_lai
  1. Sub setRowColumn(sDraw As String)
  2.     Dim oShape As Shape
  3.     Dim xRow, yCol, cHeight, cWidth, inLeft, inTop, inWidth As Integer
  4.     Dim totalRows As Single
  5.     Dim chartname As String
  6.     'totalRows = Sheets("²Î­p¹Ïªí").Range("B" & Rows.Count).End(xlUp).Row     ' ¶Ç¦^ B Äæ©Ò¨Ï¥ÎÀx¦s®æ¤§³Ì«á¤@®æ¤§¦C¸¹
  7.     '¦p§@¥Î¤¤ª«¥ó ¤£¬O¤u§@ªí ·|¦³¿ù»~ ¦p¬O¹Ïªíµ¥
  8.     totalRows = Sheets("²Î­p¹Ïªí").Range("B" & Sheets("²Î­p¹Ïªí").Rows.Count).End(xlUp).Row     ' ¶Ç¦^ B Äæ©Ò¨Ï¥ÎÀx¦s®æ¤§³Ì«á¤@®æ¤§¦C¸¹
  9.     Sheets(sDraw).Select
  10.     For Each oShape In ActiveSheet.Shapes
  11.         If oShape.Type = 3 Then
  12.             ActiveSheet.ChartObjects(oShape.Name).Activate                      ' ·Æ¹«ÂI¦b "¹Ïªí #" ¤W (¨Ò¦p¡G¥D¤O¬É¤J)¡C
  13.             '*************
  14.             '§A¤W¦¡µ{¦¡½X  ¨Ï±o§@¥Î¤¤ª«¥óÅܬ° ¹Ïªí «á­±ªºµ{¦¡¦p¦³ ¨úªº¤u§@ªíªº¦ì§} ¬Ò¶·¥[¤W  Sheets((¤u§@ªí).[A1] µ¥...
  15.             ActiveChart.SetSourceData Source:=Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows & ", ²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows & _
  16.             ", ²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$J$" & totalRows & ", ²Î­p¹Ïªí!$S$1" & totalRows)  ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¦¨¥æ»ù¡B¥D¤O¬É¤J¡B¥H¤Î´²¤á¤è¦V¡C
  17.             
  18.             'ActiveChart.SeriesCollection.Add Source:=Range("²Î­p¹Ïªí!$S$1"& totalRows)
  19.             'ActiveChart.SeriesCollection(4).Name = "=²Î­p¹Ïªí!$S$1"  '*** ¦ì§}­n¥ÎR1C1 ¤è¦¡ªí¥Ü
  20.             'ActiveChart.SeriesCollection(4).Name = "=" & [²Î­p¹Ïªí!$S$1].Address(, , xlR1C1, 1)
  21.             'ActiveChart.SeriesCollection(4).ChartType = xlColumnClustered          ' °ïÅ|ª½±ø¹Ï
  22.             xRow = 2
  23.             yCol = 1
  24.             cHeight = 488
  25.             cWidth = 450
  26.             inLeft = 30
  27.             inTop = 30
  28.             inWidth = 378
  29.             chartname = Trim(Replace(ActiveChart.Name, ActiveSheet.Name, ""))
  30.             'ActiveChart.ChartArea.Height = cHeight                           ' ±N­ì¥»³]©w¤§°ª«×½Õ¦Ü¾A«×¦ì¸m
  31.             'ActiveChart.ChartArea.Width = cWidth
  32.             'ActiveSheet.Shapes(chartname).Left = Cells(xRow, yCol).Left     ' ³]©w¦¹¹Ïªí¹ê»ÚÂ\©ñªº X¡BY ®y¼Ð¦ì¸m¡C
  33.             'ActiveSheet.Shapes(chartname).Top = Cells(xRow, yCol).Top
  34.             With ActiveChart.Parent
  35.                 .Width = cWidth                                       'ChartArea.-§ï¦¨ ¤÷¼h  Parent
  36.                 .Height = cHeight
  37.                 .Left = ActiveSheet.Cells(xRow, yCol).Left
  38.                 .Top = ActiveSheet.Cells(xRow, yCol).Top
  39.                 With .Chart.PlotArea                  ' ¹ê»Úø¹Ï°Ï¶ôªº½d³ò³]©w
  40.                   Debug.Print .InsideLeft             '  ¶Ç¦^: ø¹Ï°Ï¶ô½d³ò³]©w
  41.                   Debug.Print .InsideTop              'Debug.Print: ¦L¦C¦b->   ¦bÀ˵ø«ü¥O->§Y®É¹Bºâµøµ¡
  42.                   Debug.Print .InsideWidth
  43.                     .Left = inLeft                    '  ³]©w: ø¹Ï°Ï¶ô½d³ò
  44.                     .Top = inTop
  45.                     .Width = inWidth
  46.                 End With
  47.             End With
  48.         End If
  49.     Next
  50. End Sub
½Æ»s¥N½X

TOP

¦^´_ 4# GBKEE
ÁÂÁ±zªº¶O¤ßÀ°¦£¡A§Ú¥u²§°Ê¤F³B²z ActiveChart.SetSourceData ªº¤º®e­×¥¿ (¤§«e¿é¤J³Ì¦h¤T¶µªº­­¨î¡A¥i¯à¬O§Ú·í®É¦³¥´¿ù¦r¡A
¥H­P»~¥H¬°¤£¦æ)¡A­×¥¿¤º®e¦p¤U¡G
mainPowerForce ¼Ò²Õ­×¥¿¤º®e¡G  .SetSourceData Source:=Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows & ", ²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows & ", ²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$J$"  
                                                              &  totalRows & ", ²Î­p¹Ïªí!$V$1:²Î­p¹Ïªí!$V$" & totalRows)  ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¦¨¥æ»ù¡B¥D¤O¬É¤J¡B´²¤á¤è¦V¡B¥H¤Î¦¨¥æ¶q¡C
setRowColumn  ¼Ò²Õ­×¥¿¤º®e¡G ActiveChart.SetSourceData Source:=Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows & ", ²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows & ",
                                                           ²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$J$" & totalRows & ", ²Î­p¹Ïªí!$V$1:²Î­p¹Ïªí!$V$" & totalRows)  ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¦¨¥æ»ù¡B¥D¤O¬É¤J¡B´²¤á¤è¦V¡B¥H¤Î¦¨¥æ¶q¡C
¹ÏªíÁÙ¯uÃø·d©O¡I ©¯¼y²×©ó¶¶§Q¸Ñ¨M¤F¡A§@·~¤W¦]¬°­n±N¥Ø«e¤w¶×¤J¹ê»Ú¸ê®Æªº¸ê®Æ¦C¼Æ¬ö¿ý¡A¨Ã¦P¨B­×¥¿µ²ªG«o·S¥X¤F¤@°ï°ÝÃD (400, 1004, Automation µ¥µ¥)¡A©R³£®tÂI¥á¤F¡I
§Ú±Nµ{¦¡¥N½Xªþ¤W¡A¥HÀ°§U¦³¦¹»Ý¨Dªº¦P¦n§ä¨ì¦n¤u§@¡B©Î¦n¨Æ·~¡C
¦A¦¸¦V±z»¡Án·PÁ±z¡I
  1. Sub DrawAll()
  2.     Call drawStatistics
  3.     Call drawOmegaCharts
  4. End Sub

  5. Sub drawStatistics()
  6.     drawCharts ("²Î­p¹Ïªí")
  7. End Sub

  8. Sub drawOmegaCharts()
  9.     drawCharts ("Omega")
  10. End Sub

  11. Sub removeCharts(st As String)
  12.     Dim oShape As Shape
  13.     Dim str As String
  14.    
  15.     str = ActiveSheet.Name
  16.     Sheets(st).Select
  17.    
  18.     For Each oShape In ActiveSheet.Shapes
  19.         If oShape.Type = 3 Then
  20.             oShape.Delete
  21.         End If
  22.     Next
  23.    
  24.     Sheets(str).Select
  25. End Sub

  26. Sub drawCharts(sta As String)
  27.     Dim str As String
  28.    
  29.     str = ActiveSheet.Name
  30.     Sheets(sta).Select

  31.     Call removeCharts(sta)

  32.     Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  33.     Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  34.     Selection.Borders(xlEdgeLeft).LineStyle = xlNone
  35.    
  36.     With Selection.Borders(xlEdgeTop)
  37.         .LineStyle = xlContinuous
  38.         .ColorIndex = 0
  39.         .TintAndShade = 0
  40.         .Weight = xlThin
  41.     End With
  42.    
  43.     Selection.Borders(xlEdgeBottom).LineStyle = xlNone
  44.    
  45.     With Selection.Borders(xlEdgeRight)
  46.         .LineStyle = xlContinuous
  47.         .ColorIndex = 0
  48.         .TintAndShade = 0
  49.         .Weight = xlThin
  50.     End With
  51.    
  52.     Call mainPowerForce(sta)
  53.    
  54.     Cells(1, 1).Select
  55.     Sheets(str).Select
  56. End Sub

  57. Sub mainPowerForce(sDraw As String)
  58.     Dim totalRows As Single
  59.     Dim counter, xRow, yCol, cHeight, cWidth, inLeft, inTop, inWidth As Integer
  60.     Dim text As String
  61.     Dim chartname As String
  62.     ' Dim rXY As Range

  63.     totalRows = Sheets("²Î­p¹Ïªí").Range("B" & Rows.Count).End(xlUp).Row     ' ¶Ç¦^ B Äæ©Ò¨Ï¥ÎÀx¦s®æ¤§³Ì«á¤@®æ¤§¦C¸¹
  64.     Sheets(sDraw).Select
  65.     Cells(1, 1).Value = totalRows
  66.       
  67.    
  68.     ActiveSheet.Shapes.AddChart.Select
  69.                                              
  70.     With ActiveChart
  71.         .ChartType = xlLine               ' §é½u¹Ï
  72.         
  73.         ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¸ê®Æ¿ý¶×¤J¤§®É¶¡¡B¦¨¥æ»ù¡B¥D¤O¬É¤J¡B´²¤á¤è¦V¡B¥H¤Î¦¨¥æ¶q¡C
  74.         ' Set rXY = Union(Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows), Range("²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows), Range("²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$I$" & totalRows), Range("²Î­p¹Ïªí!$J$1:²Î­p¹Ïªí!$J$" & totalRows), Range("²Î­p¹Ïªí!$V$1:²Î­p¹Ïªí!$V$" & totalRows))
  75.         ' .SetSourceData Source:=rXY
  76.         .SetSourceData Source:=Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows & ", ²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows & _
  77.           ", ²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$J$" & totalRows & ", ²Î­p¹Ïªí!$V$1:²Î­p¹Ïªí!$V$" & totalRows)  ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¦¨¥æ»ù¡B¥D¤O¬É¤J¡B´²¤á¤è¦V¡B¥H¤Î¦¨¥æ¶q¡C
  78.                               
  79.         ' .SeriesCollection.Add Source:=Range("²Î­p¹Ïªí!$V$2:²Î­p¹Ïªí!$V$" & totalRows)
  80.         ' .SeriesCollection(4).Name = "=²Î­p¹Ïªí!$S$1"
  81.                         
  82.         .SeriesCollection(1).AxisGroup = 2
  83.         .SeriesCollection(2).ChartType = xlLine          ' §é½u¹Ï
  84.                         
  85.         .SeriesCollection(4).ChartType = xlColumnClustered          ' °ïÅ|ª½±ø¹Ï
  86.                              
  87.                              
  88.         .Axes(xlCategory).CategoryType = xlCategoryScale
  89.         .Axes(xlCategory).TickLabels.NumberFormatLocal = "hh:mm"
  90.         .Axes(xlCategory).MajorTickMark = xlNone
  91.         .Axes(xlCategory).TickLabelPosition = xlLow
  92.             
  93.         .Axes(xlValue, xlSecondary).TickLabels.NumberFormatLocal = "0_ "        ' ¥Nªíª«¥óªº®æ¦¡¥N½X¡C
  94.         .Axes(xlValue).TickLabels.NumberFormatLocal = "0_ "                     ' ¥Nªíª«¥óªº®æ¦¡¥N½X¡C
  95.     End With

  96.     With ActiveChart.SeriesCollection(1).Format.Line       ' ¦¨¥æ»ù
  97.         .Visible = msoTrue
  98.         .ForeColor.RGB = RGB(255, 0, 0)          ' ¦¨¥æ»ù«ü¼ÆÅã¥Ü¤§ÃC¦â    ---   ¬õ¦â
  99.         .Transparency = 0
  100.     End With

  101.     With ActiveChart.SeriesCollection(2).Format.Line       ' ¥D¤O¬É¤J
  102.         .Visible = msoTrue
  103.         .ForeColor.RGB = RGB(32, 178, 170)       ' ¥D¤O¬É¤J«ü¼ÆÅã¥Ü¤§ÃC¦â    ---   ®ü¬vºñ¦â
  104.         .Transparency = 0
  105.     End With

  106.     With ActiveChart.SeriesCollection(3).Format.Line       ' ´²¤á¤è¦V
  107.         .Visible = msoTrue
  108.         .ForeColor.RGB = RGB(65, 105, 225)       ' ´²¤á¤è¦V«ü¼ÆÅã¥Ü¤§ÃC¦â    ---   ¤ÑÂŦâ
  109.         .Transparency = 0
  110.     End With
  111.    
  112.     With ActiveChart.SeriesCollection(4).Format.Line       ' ¦¨¥æ¶q
  113.         .Visible = msoTrue
  114.         .ForeColor.RGB = RGB(147, 112, 219)      ' ¦¨¥æ¶q«ü¼ÆÅã¥Ü¤§ÃC¦â    ---   µµ¦â
  115.         .Transparency = 0
  116.     End With

  117.     xRow = 2
  118.     yCol = 1
  119.    
  120.     cHeight = 488
  121.     cWidth = 450
  122.     inLeft = 30
  123.     inTop = 30
  124.     inWidth = 378

  125.     text = "¥D¤O¡B´²¤á¡B»P¦¨¥æ»ù¡B¶q"

  126.     chartname = Trim(Replace(ActiveChart.Name, ActiveSheet.Name, ""))
  127.     ActiveChart.ChartArea.Height = cHeight                           ' ±N­ì¥»³]©w¤§°ª«×½Õ¦Ü¾A«×¦ì¸m
  128.     ActiveChart.ChartArea.Width = cWidth
  129.                
  130.     ActiveSheet.Shapes(chartname).Left = Cells(xRow, yCol).Left     ' ³]©w¦¹¹Ïªí¹ê»ÚÂ\©ñªº X¡BY ®y¼Ð¦ì¸m¡C
  131.     ActiveSheet.Shapes(chartname).Top = Cells(xRow, yCol).Top
  132.       
  133.     With ActiveChart.PlotArea                    ' ¹ê»Úø¹Ï°Ï¶ôªº½d³ò³]©w
  134.          .InsideLeft = inLeft
  135.          .InsideTop = inTop
  136.          .InsideWidth = inWidth
  137.     End With
  138.                
  139.     ActiveChart.SetElement (msoElementChartTitleCenteredOverlay)
  140.     ActiveChart.ChartTitle.text = text
  141.     ActiveChart.ChartTitle.Format.TextFrame2.TextRange.Font.Size = 16
  142.         
  143.     ActiveChart.Legend.Position = xlCorner     ' ±N¹Ïªí¹Ï¥Ü±q¹Ïªí³Ì¤U¤è½Õ¾ã¨ì¹Ïªí¤§¥k¤W¨¤¦ì¸m
  144.     ' Set rXY = Nothing
  145. End Sub

  146. Sub resetRC()
  147.     Call setRowColumn("²Î­p¹Ïªí")
  148.     Call setRowColumn("Omega")
  149. End Sub

  150. Sub setRowColumn(sDraw As String)
  151.     Dim oShape As Shape
  152.     Dim xRow, yCol, cHeight, cWidth, inLeft, inTop, inWidth As Integer
  153.     Dim totalRows As Single
  154.     Dim chartname As String
  155.    
  156.     totalRows = Sheets("²Î­p¹Ïªí").Range("B" & Rows.Count).End(xlUp).Row     ' ¶Ç¦^ B Äæ©Ò¨Ï¥ÎÀx¦s®æ¤§³Ì«á¤@®æ¤§¦C¸¹
  157.     Sheets(sDraw).Select
  158.    
  159.             
  160.     For Each oShape In ActiveSheet.Shapes
  161.         If oShape.Type = 3 Then
  162.             ActiveSheet.ChartObjects(oShape.Name).Activate                      ' ·Æ¹«ÂI¦b "¹Ïªí #" ¤W (¨Ò¦p¡G¥D¤O¬É¤J)¡C
  163.                
  164.             ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¸ê®Æ¿ý¶×¤J¤§®É¶¡¡B¦¨¥æ»ù¡B¥D¤O¬É¤J¡B´²¤á¤è¦V¡B¥H¤Î ¦¨¥æ¶q¡C
  165.             ' Set rXY = Union(Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows), Range("²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows), Range("²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$I$" & totalRows), Range("²Î­p¹Ïªí!$J$1:²Î­p¹Ïªí!$J$" & totalRows), Range("²Î­p¹Ïªí!$V$1:²Î­p¹Ïªí!$V$" & totalRows))
  166.             ' ActiveChart.SetSourceData Source:=rXY
  167.             ActiveChart.SetSourceData Source:=Range("²Î­p¹Ïªí!$B$1:²Î­p¹Ïªí!$B$" & totalRows & ", ²Î­p¹Ïªí!$F$1:²Î­p¹Ïªí!$F$" & totalRows & _
  168.             ", ²Î­p¹Ïªí!$I$1:²Î­p¹Ïªí!$J$" & totalRows & ", ²Î­p¹Ïªí!$V$1:²Î­p¹Ïªí!$V$" & totalRows)  ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¦¨¥æ»ù¡B¥D¤O¬É¤J¡B´²¤á¤è¦V¡B¥H¤Î¦¨¥æ¶q¡C
  169.             
  170.             ActiveChart.SeriesCollection(4).ChartType = xlColumnClustered          ' °ïÅ|ª½±ø¹Ï
  171.                                        
  172.             xRow = 2
  173.             yCol = 1
  174.                
  175.             cHeight = 488
  176.             cWidth = 450
  177.             inLeft = 30
  178.             inTop = 30
  179.             inWidth = 378
  180.             
  181.             chartname = Trim(Replace(ActiveChart.Name, ActiveSheet.Name, ""))
  182.             ActiveChart.ChartArea.Height = cHeight                           ' ±N­ì¥»³]©w¤§°ª«×½Õ¦Ü¾A«×¦ì¸m
  183.             ActiveChart.ChartArea.Width = cWidth
  184.                
  185.             ActiveSheet.Shapes(chartname).Left = Cells(xRow, yCol).Left     ' ³]©w¦¹¹Ïªí¹ê»ÚÂ\©ñªº X¡BY ®y¼Ð¦ì¸m¡C
  186.             ActiveSheet.Shapes(chartname).Top = Cells(xRow, yCol).Top
  187.         
  188.             With ActiveChart.PlotArea                    ' ¹ê»Úø¹Ï°Ï¶ôªº½d³ò³]©w
  189.                  .InsideLeft = inLeft
  190.                  .InsideTop = inTop
  191.                  .InsideWidth = inWidth
  192.             End With
  193.         End If
  194.     Next
  195.     ' Set rXY = Nothing
  196. End Sub
½Æ»s¥N½X
¥D¤O¡B´²¤á»P»ù¶q.rar (166.05 KB)

TOP

½Ð°Ý¦bdraw charts¸Ì­±,¦³¤@³s¦êªºselection.borders³]©w,¥L­Ì¬O§_¦³¯S®í·N¸q?¦³»Ý­n«O¯d¶Ü?

TOP

¦^´_ 6# pocksoft
drawCharts(sta As String) ªº sta ¬°¤u§@ªí³æ¦WºÙ¡A
Sheets(sta).Select §Y¬° ¸Ó¤u§@ªí³æ ªº¿ï¥Î¡A
Selection §Y¬O¡C

TOP

¦^´_ 6# pocksoft
¥ç¥i­×§ï¬°¡G ( ¨Ï¥Î With )
  1. Sub drawCharts(sta As String)
  2.     Dim str As String
  3.    
  4.     str = ActiveSheet.Name
  5.     Sheets(sta).Select

  6.     Call removeCharts(sta)

  7.     With Selection
  8.         .Borders(xlDiagonalDown).Style = xlNone
  9.         .Borders(xlDiagonalUp).Style = xlNone
  10.         .Borders(xlEdgeLeft).Style = xlNone
  11.    
  12.         With .Borders(xlEdgeTop)
  13.             .Style = xlContinuous
  14.             .ColorIndex = 0
  15.             .TintAndShade = 0
  16.             .Weight = xlThin
  17.         End With
  18.         
  19.         .Borders(xlEdgeBottom).Style = xlNone
  20.    
  21.         With .Borders(xlEdgeRight)
  22.             .Style = xlContinuous
  23.             .ColorIndex = 0
  24.             .TintAndShade = 0
  25.             .Weight = xlThin
  26.         End With
  27.     End With
  28.    
  29.     Call mainPowerForce(sta)
  30.    
  31.     Cells(1, 1).Select
  32.     Sheets(str).Select
  33. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2017-1-1 07:51 ½s¿è

¦^´_ 6# pocksoft
999999.png
2017-1-1 07:43

¨º¥u¬O±j½Õø¹ÏÃä®Ø¤§´y­z¡A
¹ê»Ú¦b½u«¬Ã¸»sªº¹Lµ{¤w¤©³]©w¤F¡C
3232323.png
2017-1-1 07:46

¨ä¹ê§Aªº½èºÃ¬O¹ïªº¡C(¦p¹Ï¥Ü)

TOP

        ÀR«ä¦Û¦b : ¨C¤ÑµL©Ò¨Æ¨Æ¡A¬O¤H¥Íªº®ø¶OªÌ¡A¿n·¥¡B¦³¥Î¤~¬O¤H¥Íªº³Ð³yªÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD