|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 宏2()
- Dim rng As Range, c As Range, arr
- For Each sh In ActiveSheet.DrawingObjects
- sh.Delete
- Next
- w = [a2].Width
- h = [a2].Height
- For Each rng In Union([a2:l49], [n2:u49]).Areas '两块区域范围
- ReDim arr(1 To 2000)
- s = 0
- For i = 2 To rng.EntireRow.Count + 1
- Set c = Application.Intersect(Rows(i), rng).Find("*")
- If Not c Is Nothing Then
- s = s + 1
- arr(s) = c.Address
- End If
- Next
- For i = 2 To s
- Set c1 = Range(arr(i - 1))
- Set c2 = Range(arr(i))
- x1 = c1.Left + w / 2: y1 = c1.Top + h / 2
- x2 = c2.Left + w / 2: y2 = c2.Top + h / 2
- With ActiveSheet.Shapes.AddLine(x1, y1, x2, y2).Line
- .DashStyle = msoLineSolid
- .Weight = 1.25
- .ForeColor.RGB = RGB(255, 0, 0)
- End With
- Next
- Erase arr
- Next
- End Sub
复制代码 |
|