- Sub Main()
- ReDim ar(2 To 17, 1 To 10)
- With Sheet1
- For i = 2 To 17
- k = 0
- For j = 1 To 10
- If .Cells(i, j).Interior.Color = 255 Then
- k = k + 1
- ar(i, k) = j
- End If
- Next
- Next
- For j = 1 To 10
- For i = 2 To 16
- If ar(i, j) > 0 Then
- If ar(i + 1, j) > 0 Then
- .Shapes.AddConnector msoConnectorStraight, _
- .Cells(i, ar(i, j)).Left + .Cells(i, ar(i, j)).Width / 2, _
- .Cells(i, ar(i, j)).Top + .Cells(i, ar(i, j)).Height / 2, _
- .Cells(i + 1, ar(i + 1, j)).Left + .Cells(i + 1, ar(i + 1, j)).Width / 2, _
- .Cells(i + 1, ar(i + 1, j)).Top + .Cells(i + 1, ar(i, j)).Height / 2
- Else
- Exit For
- End If
- Else
- Exit For
- End If
- Next
- Next
- End With
- End Sub
复制代码 |