|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 宏1(x0, y0, x远点, y远点, h)
For Each shp In ActiveSheet.Shapes
If shp.Name <> "CommandButton1" And shp.Name <> "SpinButton1" Then
shp.Delete
End If
Next
x0 = Cells(1, 2)
y0 = Cells(2, 2)
x远点 = Cells(3, 2)
y远点 = Cells(4, 2)
h = Cells(5, 2)
n = 1
x1 = x0
y1 = y0
For i = 1 To 4
For j = 1 To 4
With ActiveSheet.Shapes.BuildFreeform(msoEditingAuto, x1, y1)
.AddNodes msoSegmentLine, msoEditingAuto, x1 + h, y1
.AddNodes msoSegmentLine, msoEditingAuto, x1 + h, y1 + h
.AddNodes msoSegmentLine, msoEditingAuto, x1, y1 + h
.AddNodes msoSegmentLine, msoEditingAuto, x1, y1
.ConvertToShape.Select
End With
宏2 (n Mod 2)
n = n + 1
x1 = x1 + h
Next
n = n - 1
y1 = y1 + h
x1 = x0
Next
n = 2
x1 = x0
y1 = y0
For i = 1 To 4
With ActiveSheet.Shapes.BuildFreeform(msoEditingAuto, x1, y1)
.AddNodes msoSegmentLine, msoEditingAuto, x远点, y远点
.AddNodes msoSegmentLine, msoEditingAuto, x1 + h, y1
.AddNodes msoSegmentLine, msoEditingAuto, x1, y1
.ConvertToShape.Select
End With
宏2 (n Mod 2)
n = n + 1
x1 = x1 + h
Next
n = 1
For i = 1 To 4
With ActiveSheet.Shapes.BuildFreeform(msoEditingAuto, x1, y1)
.AddNodes msoSegmentLine, msoEditingAuto, x远点, y远点
.AddNodes msoSegmentLine, msoEditingAuto, x1, y1 + h
.AddNodes msoSegmentLine, msoEditingAuto, x1, y1
.ConvertToShape.Select
End With
宏2 (n Mod 2)
n = n + 1
y1 = y1 + h
Next
Range("a1").Select
End Sub
Sub 宏2(i As Integer)
If i = 1 Then
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 176, 80)
Else
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
End Sub
|
|