|
楼主 |
发表于 2011-3-15 17:00
|
显示全部楼层
回复 4楼 changxuegu 的帖子
找到一行代码 但是看不懂啊
Private Sub CommandButton1_Click()
'排列3连线
Dim Rng As Range, Rng0 As Range, Rng1 As Range, ir%
Dim C_str$, C_T$, C_L$
Application.ScreenUpdating = 0
ir = [A65536].End(xlUp).Row
For M = 1 To 3
Select Case M
Case 1
C_str = "p4:y" & ir
C_T = "p"
C_L = "y"
Case 2
C_str = "z4:ai" & ir
C_T = "z"
C_L = "ai"
Case 3
C_str = "aj4:As" & ir
C_T = "aj"
C_L = "As"
End Select
On Error Resume Next
Set Rng = Range(C_str).SpecialCells(xlCellTypeConstants, 1)
For Each Rng0 In Rng
F_Address = Rng0.Address
For Each Rng1 In Range(C_T & Rng0.Row + 1 & ":" & C_L & Rng0.Row + 1).SpecialCells(xlCellTypeConstants, 1)
If F_Address <> Rng1.Address Then
Call myLine(Rng0, Rng1)
Exit For
End If
Next
Next
C_str = ""
C_T = ""
C_L = ""
Next
Application.ScreenUpdating = 1
End Sub
Sub myLine(Cel0 As Range, Cel1)
x0 = Cel0.Left + Cel0.Width / 2
y0 = Cel0.Top + Cel0.Height / 2
x1 = Cel1.Left + Cel1.Width / 2
y1 = Cel1.Top + Cel1.Height / 2
ActiveSheet.Shapes.AddLine(x0, y0, x1, y1).Select
Selection.ShapeRange.Line.ForeColor.SchemeColor = 1 '数字改变颜色
Selection.ShapeRange.Line.Weight = msoLineRoundDot '线条的粗细,需从下面的常量中随你选择
'msoLineDash,msoLineDashDot,msoLineDashDotDot,msoLineDashStyle-Mixed,
'msoLineLongDashDot,msoLineRoundDot,mso-LineSolid 或 msoLineSquareDot。
End Sub
Private Sub CommandButton2_Click()
End Sub |
|