|
Option Explicit
Sub test()
Dim shp, i, j, flag As Boolean
ReDim shapename(1 To 4)
Sheets("一车间").Activate
For Each shp In ActiveSheet.Shapes
flag = True
With shp
If .Top > Rows(17).Top And .Top < Rows(18).Top And .Left < _
Columns(2).Left Then shapename(1) = .Name: flag = False
If .Top > Rows(17).Top And .Top < Rows(18).Top And .Left > _
Columns(10).Left Then shapename(2) = .Name: flag = False
If .Top > Rows(18).Top And .Top < Rows(19).Top And .Left < _
Columns(2).Left Then shapename(3) = .Name: flag = False
If .Top > Rows(18).Top And .Top < Rows(19).Top And .Left > _
Columns(10).Left Then shapename(4) = .Name: flag = False
If flag Then .Delete
End With
Next
For i = 6 To 11 Step 5
For j = 5 To 19
If Cells(i, j) > 0 And Cells(i, j) < 5 Then
ActiveSheet.Shapes.Range(Array(shapename(Cells(i, j)))).Select
Selection.Copy
Cells(i + 1, j).Select
ActiveSheet.Paste
Selection.Top = Cells(i + 1, j).Top + (Cells(i + 2, j).Top - _
Cells(i + 1, j).Top) / 2 - Selection.Height / 2
Selection.Left = Cells(i, j).Left + (Cells(i, j + 1).Left - _
Cells(i, j).Left) / 2 - Selection.Width / 2
End If
Next j, i
End Sub |
评分
-
3
查看全部评分
-
|