当前位置:编程学习 > VB >>

请教高手如何在EXCEL中实行列有数字自动用线条连接

如:
           A列     B列     C列
1           2
2                           7
3                   5
4                   6
5           3

如何判断表格中列中有数字,然后自动由上往下用线条自动连接。请教高手如何编写代码实现这一功能啊!谢谢! --------------------编程问答-------------------- 线条是指在excel上画一条线么?
另外怎么连接?A列2直接把线画到3? --------------------编程问答-------------------- Sub test()
    Dim r1 As Range, r2 As Range
    Dim p, q
    'ActiveSheet.DrawingObjects.Select
    'MsgBox Sheet9.Cells(1, 4).Value
    For i = 1 To 15
       [a:i].HorizontalAlignment = xlCenter
       For j = 5 To 13
             If Trim(Sheet9.Cells(i, j)) <> "" Then
             p = Sheet9.Cells(i, j).Value
            ' MsgBox (p)
             Set r1 = Rows(i).Find(p)
             End If
            
             If Trim(Sheet9.Cells(i + 1, j)) <> "" Then
             q = Sheet9.Cells(i + 1, j).Value
             'MsgBox (q)
             Set r2 = Rows(i + 1).Find(q)
             End If

       Next
      ActiveSheet.Shapes.AddLine r1.Left + r1.Width * 0.5, r1.Top + r1.Height * 0.7, r2.Left + r2.Width * 0.5, r2.Top + r2.Height * 0.3
 

    Next
    
End Sub

补充:VB ,  VBA
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,