|
楼主 |
发表于 2011-8-11 21:40
|
显示全部楼层
老大不好意思,最后个问题帮忙解决下,因为增加了4行,线条的头部乱掉了,我修改了2个代码,但是还是有问题,帮忙解决下,谢谢
Sub huax0304()
'画线
Dim n%, x%, x1, y1, x2, y2
Dim Myr%(1 To 16), nn%
For x = 2 To 17
Myr(x - 1) = Cells(65536, x).End(xlUp).Row
Next x
nn = Application.Max(Myr)
n = 1
For x = 4 To nn
aa = Cells(x, 1)
If n > 1 Then
x2 = Cells(x, 1).Offset(0, aa + 2).Left - Cells(x, 1).Offset(0, aa + 2).Width / 2: y2 = Cells(x, 1).Offset(0, aa + 2).Top + Cells(x, 1).Offset(0, aa + 2).Height / 2
ActiveSheet.Shapes.AddLine(x1, y1, x2, y2).Select
Selection.ShapeRange.Line.Weight = 1.5
Selection.ShapeRange.Line.ForeColor.SchemeColor = 6 '粉红色
x1 = x2: y1 = y2
'n = 1
GoTo 100
Else
x1 = Cells(x, 1).Offset(0, aa + 2).Left: y1 = Cells(x, 1).Offset(2, aa + 0).Top
n = n + 1
End If
100:
Next x
End Sub
Sub test()
'删除所有的线
For Each shp In ActiveSheet.Shapes
'MsgBox shp.Name
If InStr(shp.Name, "Line") > 0 Then
shp.Delete
End If
Next
End Sub
修改了Else
x1 = Cells(x, 1).Offset(0, aa + 2).Left: y1 = Cells(x, 1).Offset(2, aa + 0).Top
n = n + 1
|
|