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

[µo°Ý] ¦p¦ó±N¤G­Ó¤£¦P¦ì¸mªº¸ê®Æ²£¥Í¤@­Ó¹Ïªí©O¡H

[µo°Ý] ¦p¦ó±N¤G­Ó¤£¦P¦ì¸mªº¸ê®Æ²£¥Í¤@­Ó¹Ïªí©O¡H

¥»©«³Ì«á¥Ñ dechiuan999 ©ó 2012-4-4 20:30 ½s¿è

¦U¦ì¤j¤j¦n¡G
  
   ¤p§Ì­n±N¤@¤u§@ªíªº¤£¦P¦ì¸mªº¸ê®Æ
¦P®É²£¥Í¤@­Ó¹Ïªí¡A¦ýµLªk±N¤G­Ó¤£¦P¦ì¸mªº¸ê®Æ²£
¥Í¤@­Ó¹Ïªí¡C
   ½Ð°Ý¦U¦ì¤j¤j¦¹°ÝÃDÀ³¦p¦ó§JªA©O¡H

»¡©ú¦p¤U¡G
¹Ïªí°Ï¶ô¬°
­n±N¦¹¤G­Ó°Ï¶ôRANGE("B2:T22")¤ÎRANE("B25:F29")¦X¨Ö¨Ã
²£¥Í¤@­Ó¹Ïªí

¹Ïªí¦ì¸m¡G
RANGE("A1").RESIZE(14,20)

¤U¦C¬°¤p§Ì¤§»yªkÀ³¦p¦ó­×¥¿©O
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
        .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
        '.PlotArea.Top = 16
        '.PlotArea.Height = 160
        With .Axes(Type:=xlValue)
            .HasTitle = True
            .AxisTitle.Text = "³fª«¦s©ñ³B©Ò"
             .AxisTitle.Orientation = xlVertical
             .MaximumScale = mTotal
        End With
        '.Axes(xlCategory, xlPrimary).HasTitle = False  ''false
        '.Axes(xlValue, xlPrimary).HasTitle = False   ''false
        .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


ÁÂÁ¦U¦ì¤j¤j¡I

CHART2.rar (17.11 KB)

ÁÂÁª©¥D¤j¤j¡C
¬Ý°_¨Ó¤w±µªñ¤p§Ìªº»Ý¨D¡A
¦ý¤p§Ì¤´·Q¹F¦¨¦¹½d¨Òªº
¹Ïªí¼Ë¦¡¡C
(¤p§Ì¤w­«·s¤W¶ÇÀÉ®×)
¤U¦C¬O¤p§Ì­«·s½Õ¾ãªº¹Ïªí
¥u¬O¤Ö¤F½d³òRANGE("B25:F29")
ªº¦ì¸m¡C

»yªk¦p¤U¡G
Private Sub CommandButton1_Click()   
         
    Dim mRng As Range
    Dim mRng1 As Range
    Dim mRng2 As Range
    Dim mRng3 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("a1").Resize(14, mCol)
        
        Set mRng1 = .Range("a17").Resize(5, mCol)
        Set mRng2 = .Range("b26").Resize(5, 5)
        Set mRng3 = Union(mRng1, mRng2)       'mRng3¬O±N¤G­Ó°Ï¶ô¦X¨Ö¨Ã¾É¤J.SetSourceData Source:=mRng3, PlotBy:=xlRows «h·|¥¢±Ñ¦¬³õ
      
    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(mRng.Left, mRng.Top, mRng.Width, mRng.Height)
    With mChart
        .Name = "¦UÃö°Ï³fª«¦s©ñ³B©Ò²Î­pªí"
    End With
    mTotal = Application.WorksheetFunction.Max(mRng3)
    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 mRng3 = mSht1.Rows(24).Find(what:="Á`­p ¡G", after:=mSht1.Range("a24"), LookIn:=xlValues, SearchDirection:=xlPrevious)
    If Not mRng3 Is Nothing Then
        sumTotal = mRng3.Offset(6).Value
    End If
   
    With mChart.Chart
        .SetSourceData Source:=mRng1, PlotBy:=xlRows    '¥Ø«e°õ¦æmrng1 ¦Ó¤Ö¤Fmrng2ªº°Ï¶ô¦ì¸m¡A¦ý¦pªG§ï¬°mRng3®É«oµLªk¹F¦¨¤G­Ó°Ï¶ô
        .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

TOP

ÁÂÁª©¥D¤j¤j¡C
¤w´ú¸Õ¦¨¥\¡C
¤U¦C»yªk¯à½Ðª©¥D¤j¤jµy°µ»¡©ú¨ä¥Î·N¶Ü¡H
Do Until .SeriesCollection.Count = 4
.SeriesCollection(5).Delete
Loop

·P®¦¤j¤j¡I

TOP

ÁÂÁ¤G¦ìª©¥D¤j¤jªº¬Û§U¡C
´ú¸Õ³£«Ü¦¨¥\¡C
¤p§Ì·|¥ý¦¬¤U
¦^¥h¦n¦n¬ã¨s¡C

·P®¦¤G¦ì¤j¤j¡I

TOP

        ÀR«ä¦Û¦b : ¤â¤ß¦V¤U¬O§U¤H¡A¤â¤ß¦V¤W¬O¨D¤H¡F§U¤H§Ö¼Ö¡A¨D¤Hµh­W¡C
ªð¦^¦Cªí ¤W¤@¥DÃD