0
我想用VBA創建特定的細胞位置的排行榜位置。這裏是我的代碼如何將圖表添加到特定的細胞用VBA宏
Private Sub CommandButton1_Click()
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Chart'!$A$1:$L$2")
ActiveChart.ChartType = xlLineMarkers
Dim cht As Chart
Dim ser As Series
Set cht = ActiveChart
Set ser = cht.SeriesCollection(1)
ser.Format.Line.Visible = msoFalse
ser.Format.Line.Visible = msoTrue
ser.Format.Line.ForeColor.RGB = RGB(26, 46, 74)
ser.Format.Fill.ForeColor.RGB = RGB(26, 46, 74)
With Worksheets("Chart").ChartObjects(1).Chart
.HasTitle = True
.ChartTitle.Text = Sheets("Chart").Range("B4")
End With
Dim Srs As Series
Set Srs = ActiveChart.SeriesCollection(1)
Srs.Name = "Desired Name"
Dim ChartObj As Object
For Each ChartObj In Sheets("Chart").ChartObjects
ChartObj.Chart.Location xlLocationAsObject, "Factsheet"
Next ChartObj
End Sub
ANy想法如何我可以解決這個請好嗎?
是什麼20,20.150?我怎麼可以用我的代碼來實現這個? –
我已經更新了我的工作的例子,清楚地表明瞭ChartObjects.Add(左,上,寬度,高度)方法的答案。 – danpeall