Sub test()
Dim Rng, L, W, H, moveH, x
Set Rng = Range("a1:h6") '颜色区域
L = Rng.Left
W = Rng.Width / chartCount
H = W '为得到正圆
moveH = (Rng.Height - H) / 2 '偏移高度
For Each x In ActiveSheet.Shapes
If x.Type = 1 Then
x.Left = L: L = L + W
x.Top = Rng.Top + moveH
x.Width = W
x.Height = H
End If
Next
End Sub
'求自选图形的个数(如果全是自选图形,可用 ActiveSheet.Shapes.Count )
Function chartCount() As Integer
Dim x, s
For Each x In ActiveSheet.Shapes
If x.Type = 1 Then s = s + 1
Next
chartCount = s
End Function
排成一行.rar
(15.79 KB, 下载次数: 10)