发布网友 发布时间:2022-04-19 14:56
共1个回答
热心网友 时间:2023-06-19 12:47
灞曞紑鍏ㄩ儴Sub test()
Dim i%, nm$, r%, a$
r = Cells(Rows.Count, 1).End(3).Row
For i = 2 To r
a = Cells(i, 1).Resize(1, 4).Address
Range("Sheet1!$A$1:$D$1," & a).Select
ActiveSheet.Shapes.AddChart2(254, xlPie).Select
ActiveChart.SetSourceData Source:=Range("Sheet1!$A$1:$D$1," & a)
ActiveChart.Parent.Cut
Cells(i, 5).Select
ActiveSheet.Paste
ActiveChart.SetElement (msoElementLegendNone)
ActiveChart.SetElement (msoElementChartTitleNone)
nm = Application.Substitute(ActiveChart.Name, ActiveSheet.Name & " ", "")
ActiveSheet.Shapes(nm).LockAspectRatio = msoTrue
ActiveSheet.Shapes(nm).Height = Cells(i, 1).Height
Next
[a1].Select
End Sub