- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 118
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-5-22
|
¦^´_ 3# dechiuan999
¸Õ¸Õ¬Ý- Sub aa()
-
- '³fª«¦s©ñ³B²Îp¹Ïªí
-
- Dim mRng As Range
- Dim mRng1 As Range
- Dim mRng2 As Range
- Dim mRng3 As Range
- Dim mRng4 As Range
- Dim mTotal%, mRow$
- Dim oldmonth
- Dim mSht1 As Worksheet
- Dim mChart As ChartObject
- Dim mCol%, sumTotal As Long
-
- Application.ScreenUpdating = False
-
- Set mSht1 = Worksheets("·í¤ë²Îpªí¤Î¹Ïªí")
- With mSht1
- mCol = .Range("a16").End(xlToRight).Column
- Set mRng = .Range("a17").Resize(5, mCol)
- Set mRng1 = .Range("b25").Resize(5, .Range("b25").End(xlToRight).Column - 1)
- Set mRng2 = Union(mRng, mRng1)
- Set mRng3 = .Range("a1").Resize(14, mCol)
- End With
-
- oldmonth = Month(Date)
- If oldmonth = "1" Then
- oldmonth = "12"
- Else
- oldmonth = oldmonth - 1
- End If
- Call changeMonth(oldmonth)
- Application.ScreenUpdating = False
-
- Set mChart = mSht1.ChartObjects.Add(mRng3.Left, mRng3.Top, mRng3.Width, mRng3.Height)
- With mChart
- .Name = "¦UÃö°Ï³fª«¦s©ñ³B©Ò²Îpªí"
- End With
-
- mTotal = Application.WorksheetFunction.Max(mRng2)
- Select Case mTotal
-
- Case 1 To 50
- mTotal = "50"
- Case 51 To 100
- mTotal = "100"
- Case 101 To 150
- mTotal = "150"
- Case 151 To 200
- mTotal = "200"
- Case 201 To 250
- mTotal = "250"
- Case 251 To 300
- mTotal = "300"
- Case 301 To 350
- mTotal = "350"
- Case 351 To 400
- mTotal = "400"
- Case 401 To 450
- mTotal = "450"
- Case 451 To 500
- mTotal = "500"
- End Select
-
- Set mRng4 = mSht1.Rows(24).Find(what:="Á`p ¡G", after:=mSht1.Range("a24"), LookIn:=xlValues, SearchDirection:=xlPrevious)
- If Not mRng4 Is Nothing Then
- sumTotal = mRng4.Offset(6).Value
- End If
-
- With mChart.Chart
- .SetSourceData Source:=mRng2, PlotBy:=xlRows
- 'Ó§O³]¸m¼Æ¦C½d³ò
- .SeriesCollection(1).XValues = _
- "=(·í¤ë²Îpªí¤Î¹Ïªí!R17C2:R17C20,·í¤ë²Îpªí¤Î¹Ïªí!R25C2:R25C6)"
- .SeriesCollection(1).Values = _
- "=(·í¤ë²Îpªí¤Î¹Ïªí!R18C2:R18C20,·í¤ë²Îpªí¤Î¹Ïªí!R26C2:R26C6)"
- .SeriesCollection(1).Name = "=·í¤ë²Îpªí¤Î¹Ïªí!R18C1"
- .SeriesCollection(2).XValues = _
- "=(·í¤ë²Îpªí¤Î¹Ïªí!R17C2:R17C20,·í¤ë²Îpªí¤Î¹Ïªí!R25C2:R25C6)"
- .SeriesCollection(2).Values = _
- "=(·í¤ë²Îpªí¤Î¹Ïªí!R19C2:R19C20,·í¤ë²Îpªí¤Î¹Ïªí!R27C2:R27C6)"
- .SeriesCollection(2).Name = "=·í¤ë²Îpªí¤Î¹Ïªí!R19C1"
- .SeriesCollection(3).XValues = _
- "=(·í¤ë²Îpªí¤Î¹Ïªí!R17C2:R17C20,·í¤ë²Îpªí¤Î¹Ïªí!R25C2:R25C6)"
- .SeriesCollection(3).Values = _
- "=(·í¤ë²Îpªí¤Î¹Ïªí!R20C2:R20C20,·í¤ë²Îpªí¤Î¹Ïªí!R28C2:R28C6)"
- .SeriesCollection(3).Name = "=·í¤ë²Îpªí¤Î¹Ïªí!R20C1"
- .SeriesCollection(4).XValues = _
- "=(·í¤ë²Îpªí¤Î¹Ïªí!R17C2:R17C20,·í¤ë²Îpªí¤Î¹Ïªí!R25C2:R25C6)"
- .SeriesCollection(4).Values = _
- "=(·í¤ë²Îpªí¤Î¹Ïªí!R21C2:R21C20,·í¤ë²Îpªí¤Î¹Ïªí!R29C2:R29C6)"
- .SeriesCollection(4).Name = "=·í¤ë²Îpªí¤Î¹Ïªí!R21C1"
- '§R°£¿ù»~¼Æ¦C
- Do Until .SeriesCollection.Count = 4
- .SeriesCollection(5).Delete
- Loop
- .Location Where:=xlLocationAsObject, Name:="·í¤ë²Îpªí¤Î¹Ïªí"
- .HasTitle = True
- .ChartType = xlColumnClustered
- .HasLegend = True
- .ApplyDataLabels xlDataLabelsShowValue
- .Axes(xlCategory).TickLabels.Orientation = xlHorizontal
- .ChartTitle.Characters.Text = " " & oldmonth & " ¤ë¥÷¦UÃö°Ï³fª«¦s©ñ³B©Ò²Îpªí (" & sumTotal & " ¥÷)"
- .ChartTitle.Font.Bold = False
- .ChartTitle.Font.Size = 12
- With .Axes(Type:=xlValue)
- .HasTitle = True
- .AxisTitle.Text = "³fª«¦s©ñ³B©Ò"
- .AxisTitle.Orientation = xlVertical
- .MaximumScale = mTotal
- End With
- .ChartArea.Font.Size = 8
- .ChartTitle.Font.Size = 10
- End With
-
- Application.ScreenUpdating = True
-
- Set mRng = Nothing
- Set mRng1 = Nothing
- Set mRng2 = Nothing
- Set mRng3 = Nothing
- Set mChart = Nothing
- End Sub
½Æ»s¥N½X |
|