如何用垂直线连接两个选定的单元格?
如果加入单元格 F6 和 F11,

有人可能会输入
=LINEJOIN(F6,F11)
Run Code Online (Sandbox Code Playgroud)
并获得一条从 F6 下边缘中部一直延伸到 F11 上边缘中部的居中垂直线。

这是一个家谱项目。
试试这个
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)
| 归档时间: |
|
| 查看次数: |
109 次 |
| 最近记录: |