-1
我有一個問題,準備宏將在工作表中選擇3個範圍,然後用這些數據創建3張圖表的新工作表。我該如何準備? 這是我現在所擁有的,但不起作用:ActiveChart.Location Where:="Inwestycje wykresy"
被突出顯示,並且出現'Type mismatch'錯誤。 我還必須包含圖表的尺寸和位置嗎? 這裏是我的代碼:excel vba在新工作表中的多個圖表
Sub InwestycjeWykresy()
Range("B3:N5").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B3:N5"), PlotBy:=xlRows
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Alerty"
End With
Worksheets("Inwestycje").Activate
Range("B6:N7").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B6:N7"), PlotBy:=xlRows
ActiveChart.Location Where:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Eskalacje"
End With
Worksheets("Inwestycje").Activate
Range("B8:N10").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B8:N10"), PlotBy:=xlRows
ActiveChart.Location Where:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Nadzor"
End With
End Sub
感謝蒂姆,它解決了我的錯誤!然而,現在我在一張新表中有這3張圖表,但他們沒有正確定位 - 第一張紙張覆蓋整張紙張,另外兩張紙張很小並且彼此覆蓋。可能我需要包含一些關於它們的大小和位置的信息 – lucass3231
[This](http://peltiertech.com/Excel/ChartsHowTo/ResizeAndMoveAChart.html)詳細介紹了實現該目的的最佳方法。 –
我將此添加到每一個圖表隨着ActiveChart.Parent .HasTitle =真 .ChartTitle.Characters.Text = 「Alerty」 .Height = 325 '調整 .WIDTH = 500' 調整 .TOP = 100'重新定位 .Left = 100'重新定位 以 – lucass3231