1
更新:我稍微修改了Nick提供的代碼。最初,這個帶有Rng.Offset的代碼使用了大量的數據來製作雷達圖表。例如:從(A1:E1):(A2:E2)(這首先是罰款),但是然後:(A1:E1):(A3:E3),(A1:E1):(A4:E4) ,(A1:E1):(A5:E5)等等...相反,我想每次只選擇一個額外的行,因此:(A1:E1)+(A3:E3),(A1:E1 )+(A4:E4),(A1:E1)+(A5:E5)。更新:通過幾個範圍循環?
Sub MultipleRadarCharts()
Dim i As Integer
Dim Rng As Range
Set Rng = Sheets("Indices4Pilares (4)").Range("A1:E1")
For i = 2 To 36
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlRadarMarkers
'ActiveChart.SetSourceData Source:=Sheets("Indices4Pilares (4)").Range(Rng, Rng.Offset(i - 1, 0))
'ActiveChart.SetSourceData Source:=Sheets("Indices4Pilares (4)").Range(Rng, Range(Cells(i, 1), Cells(i, 5)))
ActiveChart.SetSourceData Source:=Sheets("Indices4Pilares (4)").Union(Range(Cells(1, 1), Cells(1, 5)), Range(Cells(i, 1), Cells(i, 5))).Select
ActiveChart.Legend.Delete
Next i
Set Rng = Nothing
End Sub
=====
:)我只是爲了從一個Excel表中獲取雷達圖創造了這個代碼。
第一行有變量的名稱,然後(從第2行到第36行)有值。問題是,我堅持要與之簡化代碼爲「for循環」,但我不能讓它工作:(
這是原始代碼,我想簡化...
Sub Macro2()
Range("A1:E1,A2:E2").Select
Range("A2").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlRadarMarkers
ActiveChart.SetSourceData Source:=Range(_
"'Indices4Pilares (3)'!$A$1:$E$1,'Indices4Pilares (3)'!$A$2:$E$2")
ActiveChart.Legend.Select
Selection.Delete
Range("A1:E1,A3:E3").Select
Range("A3").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlRadarMarkers
ActiveChart.SetSourceData Source:=Range(_
"'Indices4Pilares (3)'!$A$1:$E$1,'Indices4Pilares (3)'!$A$3:$E$3")
ActiveChart.Legend.Select
Selection.Delete
Range("A1:E1,A4:E4").Select
Range("A4").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlRadarMarkers
ActiveChart.SetSourceData Source:=Range(_
"'Indices4Pilares (3)'!$A$1:$E$1,'Indices4Pilares (3)'!$A$4:$E$4")
ActiveChart.Legend.Select
Selection.Delete
Range("A1:E1,A5:E5").Select
Range("A5").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlRadarMarkers
ActiveChart.SetSourceData Source:=Range(_
"'Indices4Pilares (3)'!$A$1:$E$1,'Indices4Pilares (3)'!$A$5:$E$5")
ActiveChart.Legend.Select
Selection.Delete
End Sub
謝謝尼克我剛纔用你的代碼。然而,到目前爲止,我仍然有一些問題,它本來,與Rng.Offset你的代碼需要數據的大範圍進行。例如:從(A1:E1):(A2:E2)(這首先是罰款),但它會變成:(A1:E1):(A3:E3),(A1:E1):(A4:E4),(A1:E1):(A5:E5), (A1:E1)+(A3:E3),(A1:E1)+(A4:E4),(A1:E1) +(A5:E5) – Marco
@Marco - 剛剛編輯的答案應該提供非連續的範圍。 –