- 帖子
- 231
- 主題
- 55
- 精華
- 0
- 積分
- 293
- 點名
- 0
- 作業系統
- winxp
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 男
- 來自
- KEELUNG
- 註冊時間
- 2010-7-24
- 最後登錄
- 2018-8-28
|
[發問] 如何將產生的圖表存放在指定工作表的位置上呢?
各位大大好:
小弟好久沒有上來向各
位大大請安。還請各位大大見諒。
現小弟有一問題想請各位
大大相助。問題如下:
小弟想修改下列語法,
當按下SHEET1工作表上的按鈕時,
將產生的圖表存放在指定位置。
例如H1:L12的位置
請問如何修改呢?
Private Sub CommandButton1_Click()
Dim mRng As Range
Dim mRng1 As Range
Dim mRng2 As Range
Dim mRng3 As Range
Dim mTotal%
Dim oldMonth
Dim mSht As Worksheet
Dim mRow As Integer
Set mSht = Worksheets(1)
With mSht
mRow = .Range("a1").End(xlDown).Row
Set mRng = .Range("g1:l" & mRow)
Set mRng1 = .Range("a2:a12")
Set mRng2 = .Range("f2:f12")
mTotal = Application.WorksheetFunction.Max(mRng2)
Set mRng3 = Union(mRng1, mRng2)
End With
oldMonth = Month(Date) - 1
Application.ScreenUpdating = False
Charts.Add
Select Case mTotal
Case 1 To 100
mTotal = "100"
Case 101 To 200
mTotal = "200"
Case 201 To 300
mTotal = "300"
Case 301 To 400
mTotal = "400"
Case 401 To 500
mTotal = "500"
Case esle
mTotal = mTotal
End Select
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.SetSourceData Source:=mRng3, PlotBy:=xlColumns
.HasTitle = True
.ChartType = xlColumnClustered
.HasLegend = False
.ApplyDataLabels xlDataLabelsShowValue
'.Axes(xlCategory).TickLabels.Orientation = xlHorizontal
.ChartTitle.Characters.Text = oldMonth & " 月份統計表"
.ChartTitle.Font.Bold = False
.ChartTitle.Font.Size = 12
.PlotArea.Top = 16
.PlotArea.Height = 160
.Axes(xlValue).MaximumScale = mTotal
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.ChartArea.Font.Size = 8
.ChartTitle.Font.Size = 10
End With
Application.ScreenUpdating = True '
End Sub |
-
-
TEST二.rar
(12.63 KB)
|