- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
¦^´_ 4# GBKEE
ÁÂÁ±zªº¶O¤ßÀ°¦£¡A§Ú¥u²§°Ê¤F³B²z ActiveChart.SetSourceData ªº¤º®e×¥¿ (¤§«e¿é¤J³Ì¦h¤T¶µªº¨î¡A¥i¯à¬O§Ú·í®É¦³¥´¿ù¦r¡A
¥HP»~¥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- Sub DrawAll()
- Call drawStatistics
- Call drawOmegaCharts
- End Sub
- Sub drawStatistics()
- drawCharts ("²Îp¹Ïªí")
- End Sub
- Sub drawOmegaCharts()
- drawCharts ("Omega")
- End Sub
- Sub removeCharts(st As String)
- Dim oShape As Shape
- Dim str As String
-
- str = ActiveSheet.Name
- Sheets(st).Select
-
- For Each oShape In ActiveSheet.Shapes
- If oShape.Type = 3 Then
- oShape.Delete
- End If
- Next
-
- Sheets(str).Select
- End Sub
- Sub drawCharts(sta As String)
- Dim str As String
-
- str = ActiveSheet.Name
- Sheets(sta).Select
- Call removeCharts(sta)
- Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- Selection.Borders(xlEdgeLeft).LineStyle = xlNone
-
- With Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
-
- Selection.Borders(xlEdgeBottom).LineStyle = xlNone
-
- With Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
-
- Call mainPowerForce(sta)
-
- Cells(1, 1).Select
- Sheets(str).Select
- End Sub
- Sub mainPowerForce(sDraw As String)
- Dim totalRows As Single
- Dim counter, xRow, yCol, cHeight, cWidth, inLeft, inTop, inWidth As Integer
- Dim text As String
- Dim chartname As String
- ' Dim rXY As Range
- totalRows = Sheets("²Îp¹Ïªí").Range("B" & Rows.Count).End(xlUp).Row ' ¶Ç¦^ B Äæ©Ò¨Ï¥ÎÀx¦s®æ¤§³Ì«á¤@®æ¤§¦C¸¹
- Sheets(sDraw).Select
- Cells(1, 1).Value = totalRows
-
-
- ActiveSheet.Shapes.AddChart.Select
-
- With ActiveChart
- .ChartType = xlLine ' §é½u¹Ï
-
- ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¸ê®Æ¿ý¶×¤J¤§®É¶¡¡B¦¨¥æ»ù¡B¥D¤O¬É¤J¡B´²¤á¤è¦V¡B¥H¤Î¦¨¥æ¶q¡C
- ' 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))
- ' .SetSourceData Source:=rXY
- .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
-
- ' .SeriesCollection.Add Source:=Range("²Îp¹Ïªí!$V$2:²Îp¹Ïªí!$V$" & totalRows)
- ' .SeriesCollection(4).Name = "=²Îp¹Ïªí!$S$1"
-
- .SeriesCollection(1).AxisGroup = 2
- .SeriesCollection(2).ChartType = xlLine ' §é½u¹Ï
-
- .SeriesCollection(4).ChartType = xlColumnClustered ' °ïÅ|ª½±ø¹Ï
-
-
- .Axes(xlCategory).CategoryType = xlCategoryScale
- .Axes(xlCategory).TickLabels.NumberFormatLocal = "hh:mm"
- .Axes(xlCategory).MajorTickMark = xlNone
- .Axes(xlCategory).TickLabelPosition = xlLow
-
- .Axes(xlValue, xlSecondary).TickLabels.NumberFormatLocal = "0_ " ' ¥Nªíª«¥óªº®æ¦¡¥N½X¡C
- .Axes(xlValue).TickLabels.NumberFormatLocal = "0_ " ' ¥Nªíª«¥óªº®æ¦¡¥N½X¡C
- End With
- With ActiveChart.SeriesCollection(1).Format.Line ' ¦¨¥æ»ù
- .Visible = msoTrue
- .ForeColor.RGB = RGB(255, 0, 0) ' ¦¨¥æ»ù«ü¼ÆÅã¥Ü¤§ÃC¦â --- ¬õ¦â
- .Transparency = 0
- End With
- With ActiveChart.SeriesCollection(2).Format.Line ' ¥D¤O¬É¤J
- .Visible = msoTrue
- .ForeColor.RGB = RGB(32, 178, 170) ' ¥D¤O¬É¤J«ü¼ÆÅã¥Ü¤§ÃC¦â --- ®ü¬vºñ¦â
- .Transparency = 0
- End With
- With ActiveChart.SeriesCollection(3).Format.Line ' ´²¤á¤è¦V
- .Visible = msoTrue
- .ForeColor.RGB = RGB(65, 105, 225) ' ´²¤á¤è¦V«ü¼ÆÅã¥Ü¤§ÃC¦â --- ¤ÑÂŦâ
- .Transparency = 0
- End With
-
- With ActiveChart.SeriesCollection(4).Format.Line ' ¦¨¥æ¶q
- .Visible = msoTrue
- .ForeColor.RGB = RGB(147, 112, 219) ' ¦¨¥æ¶q«ü¼ÆÅã¥Ü¤§ÃC¦â --- µµ¦â
- .Transparency = 0
- End With
- xRow = 2
- yCol = 1
-
- cHeight = 488
- cWidth = 450
- inLeft = 30
- inTop = 30
- inWidth = 378
- text = "¥D¤O¡B´²¤á¡B»P¦¨¥æ»ù¡B¶q"
- chartname = Trim(Replace(ActiveChart.Name, ActiveSheet.Name, ""))
- ActiveChart.ChartArea.Height = cHeight ' ±N쥻³]©w¤§°ª«×½Õ¦Ü¾A«×¦ì¸m
- ActiveChart.ChartArea.Width = cWidth
-
- ActiveSheet.Shapes(chartname).Left = Cells(xRow, yCol).Left ' ³]©w¦¹¹Ïªí¹ê»ÚÂ\©ñªº X¡BY ®y¼Ð¦ì¸m¡C
- ActiveSheet.Shapes(chartname).Top = Cells(xRow, yCol).Top
-
- With ActiveChart.PlotArea ' ¹ê»Úø¹Ï°Ï¶ôªº½d³ò³]©w
- .InsideLeft = inLeft
- .InsideTop = inTop
- .InsideWidth = inWidth
- End With
-
- ActiveChart.SetElement (msoElementChartTitleCenteredOverlay)
- ActiveChart.ChartTitle.text = text
- ActiveChart.ChartTitle.Format.TextFrame2.TextRange.Font.Size = 16
-
- ActiveChart.Legend.Position = xlCorner ' ±N¹Ïªí¹Ï¥Ü±q¹Ïªí³Ì¤U¤è½Õ¾ã¨ì¹Ïªí¤§¥k¤W¨¤¦ì¸m
- ' Set rXY = Nothing
- End Sub
- Sub resetRC()
- Call setRowColumn("²Îp¹Ïªí")
- Call setRowColumn("Omega")
- End Sub
- Sub setRowColumn(sDraw As String)
- Dim oShape As Shape
- Dim xRow, yCol, cHeight, cWidth, inLeft, inTop, inWidth As Integer
- Dim totalRows As Single
- Dim chartname As String
-
- totalRows = Sheets("²Îp¹Ïªí").Range("B" & Rows.Count).End(xlUp).Row ' ¶Ç¦^ B Äæ©Ò¨Ï¥ÎÀx¦s®æ¤§³Ì«á¤@®æ¤§¦C¸¹
- Sheets(sDraw).Select
-
-
- For Each oShape In ActiveSheet.Shapes
- If oShape.Type = 3 Then
- ActiveSheet.ChartObjects(oShape.Name).Activate ' ·Æ¹«ÂI¦b "¹Ïªí #" ¤W (¨Ò¦p¡G¥D¤O¬É¤J)¡C
-
- ' ¹Ï¥Ü·|¤À§OÅã¥Ü¥X ¸ê®Æ¿ý¶×¤J¤§®É¶¡¡B¦¨¥æ»ù¡B¥D¤O¬É¤J¡B´²¤á¤è¦V¡B¥H¤Î ¦¨¥æ¶q¡C
- ' 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))
- ' ActiveChart.SetSourceData Source:=rXY
- 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
-
- ActiveChart.SeriesCollection(4).ChartType = xlColumnClustered ' °ïÅ|ª½±ø¹Ï
-
- xRow = 2
- yCol = 1
-
- cHeight = 488
- cWidth = 450
- inLeft = 30
- inTop = 30
- inWidth = 378
-
- chartname = Trim(Replace(ActiveChart.Name, ActiveSheet.Name, ""))
- ActiveChart.ChartArea.Height = cHeight ' ±N쥻³]©w¤§°ª«×½Õ¦Ü¾A«×¦ì¸m
- ActiveChart.ChartArea.Width = cWidth
-
- ActiveSheet.Shapes(chartname).Left = Cells(xRow, yCol).Left ' ³]©w¦¹¹Ïªí¹ê»ÚÂ\©ñªº X¡BY ®y¼Ð¦ì¸m¡C
- ActiveSheet.Shapes(chartname).Top = Cells(xRow, yCol).Top
-
- With ActiveChart.PlotArea ' ¹ê»Úø¹Ï°Ï¶ôªº½d³ò³]©w
- .InsideLeft = inLeft
- .InsideTop = inTop
- .InsideWidth = inWidth
- End With
- End If
- Next
- ' Set rXY = Nothing
- End Sub
½Æ»s¥N½X
¥D¤O¡B´²¤á»P»ù¶q.rar (166.05 KB)
|
|