如何用垂直线连接单元格?

Mik*_*e62 0 excel vba

如何用垂直线连接两个选定的单元格?

如果加入单元格 F6 和 F11,
要加入的细胞

有人可能会输入

=LINEJOIN(F6,F11)
Run Code Online (Sandbox Code Playgroud)

并获得一条从 F6 下边缘中部一直延伸到 F11 上边缘中部的居中垂直线。
连接细胞

这是一个家谱项目。

Tim*_*ams 5

试试这个

Function LineJoin(rngStart As Range, rngEnd As Range)
    Dim shp As Shape, nm As String, ws As Worksheet
    Dim st, sl, et, el
    
    Set ws = Application.ThisCell.Worksheet ' `ThisCell` = the cell with the formula
    'a [unique] name for the line
    nm = rngStart.Address(False, False) & "_" & rngEnd.Address(False, False)
    
    On Error Resume Next
    ws.Shapes(nm).Delete  'remove any already-added line
    On Error GoTo 0
    
    'calculate start/end left & top
    sl = rngStart.Left + (rngStart.Width / 2)
    st = rngStart.Top + rngStart.Height
    el = rngEnd.Left + (rngEnd.Width / 2)
    et = rngEnd.Top
    
    Set shp = ws.Shapes.AddConnector(msoConnectorStraight, sl, st, el, et)
    shp.Name = nm  'name the line
    LineJoin = nm  'return the name of the added line
End Function
Run Code Online (Sandbox Code Playgroud)

  • @BigBen - 我也是,但我猜 UDF 这样做的风险很低,因为它不太可能弄乱计算树? (2认同)