目前在學習VBA畫圖表中
現在使用下面的VBA碼,跑出來的標示太大了
請問要加入什麼才可以將標示調整大小呢?

Sub H_Sample003()
Dim myCht As Chart
Dim myChtobj As ChartObject
Dim mySht1 As Worksheet
Dim mySht2 As Worksheet
Dim myRng1 As Range
Dim myRng2 As Range
Dim myRng3 As Range
'指定基礎資料
Set mySht1 = ThisWorkbook.Worksheets("H_Data01") '資料表
Set mySht2 = ThisWorkbook.Worksheets("Sheet1") '要貼上的工作表
Set myRng1 = mySht1.Range("E2:E21") '資料範圍
Set myRng2 = mySht1.Range("F2:F21")
Set myRng3 = mySht1.Range("E1:F1")
For Each myChtobj In mySht2.ChartObjects
myChtobj.Delete
Next
Set myCht = Charts.Add
With myCht
.ChartType = xlXYScatter
.SetSourceData Source:=mySht1.Range("A1"), PlotBy:=xlRows
.SeriesCollection(1).XValues = myRng1
.SeriesCollection(1).Values = myRng2
.Location Where:=xlLocationAsObject, Name:=mySht2.Name
End With
Set myCht = mySht2.ChartObjects(mySht2.ChartObjects.Count).Chart
With mySht2.Shapes(mySht2.Shapes.Count)
.Top = 10
.Left = 10
.Width = 300
.Height = 300
End With
With myCht
.HasLegend = False
.HasTitle = True
.ChartTitle.Characters.Text = _
myRng3.Cells(1).Value & "-" & myRng3.Cells(2).Value
With .Axes(xlCategory, xlPrimary)
.HasTitle = True
.AxisTitle.Characters.Text = myRng3.Cells(1).Value
End With
With .Axes(xlValue, xlPrimary)
.HasTitle = True
.AxisTitle.Characters.Text = myRng3.Cells(2).Value
.AxisTitle.Orientation = xlHorizontal
End With
With .PlotArea
.Left = 20
.Top = 20
.Width = 250
.Height = 250
With .Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
End With
With .ChartTitle
.Left = 10
.Top = 5
.Font.Size = 10
End With

End With
mySht2.Range("A1").Activate
Set myRng1 = Nothing '釋放物件
Set myRng2 = Nothing
Set myRng3 = Nothing
Set mySht1 = Nothing
Set mySht2 = Nothing
Set myCht = Nothing
Set myChtobj = Nothing
End Sub
文章分享
評分
評分
複製連結

今日熱門文章 網友點擊推薦!