20220509 1416 

 

REF

[1] "https://wellsr.com/vba/2015/excel/draw-lines-or-arrows-between-cells-with-vba/"

 

code

Sub zConnectTwoCells_without_box_straightLine()

'beg
x1 = Selection.Areas.Item(1).Left
w1 = Selection.Areas.Item(1).Width
y1 = Selection.Areas.Item(1).Top
h1 = Selection.Areas.Item(1).Height

'end
x2 = Selection.Areas.Item(2).Left
y2 = Selection.Areas.Item(2).Top
w2 = Selection.Areas.Item(2).Width
h2 = Selection.Areas.Item(2).Height

'if beg is left of end
If (x1 < x2) Then
  ActiveSheet.Shapes.AddConnector(msoConnectorStraight, x1 + w1, y1 + h1 / 2, x2, y2 + h2 / 2).Select
Else
  ActiveSheet.Shapes.AddConnector(msoConnectorStraight, x1, y1 + h1 / 2, x2 + w2, y2 + h2 / 2).Select
End If


With Selection.ShapeRange.Line
  .BeginArrowheadStyle = msoArrowheadNone
  .EndArrowheadStyle = msoArrowheadOpen
  '.Weight = 1.75
  .ForeColor.RGB = RGB(0, 0, 0)
End With

End Sub

 

activesheet.shapes.addline(x1+w1,y1+h1/2,x2,y2+h2/2).select

'[PA] 업무자동화 > [XL]Excel & VBA' 카테고리의 다른 글

XL Personal.xlsb Macro  (0) 2022.05.10
XL Ribbon menu - customize, add, export  (0) 2022.05.10
XL VBA kitchen utils  (0) 2022.05.10
색깔 있는 셀 개수 세기  (0) 2022.04.08
XL VBA Filter Auto, Advanced  (0) 2022.03.04
Posted by Weneedu
,


출처: https://privatedevelopnote.tistory.com/81 [개인노트]