|
楼主 |
发表于 2023-9-7 13:06
|
显示全部楼层
12个长方形,6个左括号
- Option Explicit
- Option Base 1
- Sub Main()
- Dim ar, i%, l#, t#, h#
- Dim shp As Shape, cr
- ar = RandomData(12)
- cr = Array(&HFFCC99, &HF6D0A2, &HEDD5AB, &HE4D9B4, &HDADEBE, &HD1E3C7, &HC8E7D0, &HBFECD9, &HB5F1E3, &HACF5EC, &HA3FAF5, &H99FFFF)
- With ActiveSheet
- Set shp = .Shapes("Rect1")
- t = shp.Top
- l = shp.Left
- shp.Width = ar(1)
- shp.Fill.ForeColor.RGB = cr(1)
- shp.TextFrame.Characters.Text = Format(1 & -1, "mmmm")
- For i = 2 To 12
- t = t + shp.Height + 15
- With .Shapes("Rect" & i)
- .Left = l
- .Top = t
- .Width = ar(i)
- .Fill.ForeColor.RGB = cr(i)
- .TextFrame.Characters.Text = Format(i & -1, "mmmm")
- End With
- Next
- For i = 1 To 6
- Set shp = .Shapes("Rect" & i)
- h = .Shapes("Rect" & 13 - i).Top - shp.Top
- With .Shapes("Brac" & i)
- .Left = l - .Width
- .Top = shp.Top + shp.Height / 2
- .Height = h
- .Adjustments.Item(1) = 0.7
- End With
- Next
- End With
-
- End Sub
- Private Function RandomData(n0%)
- Dim ar, i%
- ReDim ar(n0)
- Randomize
- For i = 1 To n0
- ar(i) = Int(Rnd * 100) + 150
- Next
- RandomData = ar
- End Function
复制代码 |
|