20230624 2255 
 
1, 가로 화살표 선(오른쪽으로 가는)

Sub kcDrawHLine()
Dim Obj As Shape
L1 = Selection.Cells(1).Left
cnt = Selection.Columns.Count
L2 = Selection.Cells(cnt).Left + Selection.Cells(cnt).Width 'right
T1 = Selection.Cells(1).Top + Selection.Cells(1).Height / 2
Set Obj = ActiveSheet.Shapes.AddLine(L1, T1, L2, T1)
With Obj.Line
  .Weight = 3
  .EndArrowheadStyle = msoArrowheadTriangle
  .EndArrowheadLength = msoArrowheadLengthMedium
  .EndArrowheadWidth = msoArrowheadWidthMedium
End With
End Sub

 
2, 가로 화살표 선(왼쪽으로 가는)

Sub kcDrawHLine_reverse()
Dim Obj As Shape
L1 = Selection.Cells(1).Left
cnt = Selection.Columns.Count
L2 = Selection.Cells(cnt).Left + Selection.Cells(cnt).Width 'right
T1 = Selection.Cells(1).Top + Selection.Cells(1).Height / 2
Set Obj = ActiveSheet.Shapes.AddLine(L2, T1, L1, T1)
With Obj.Line
  .Weight = 3
  .EndArrowheadStyle = msoArrowheadTriangle
  .EndArrowheadLength = msoArrowheadLengthMedium
  .EndArrowheadWidth = msoArrowheadWidthMedium
End With
End Sub

 
3, 세로 화살표 선 (아래 방향)

Sub kcDrawVLine()
Dim Obj As Shape

x1 = Selection.Cells(1).Left + Selection.Cells(1).Width / 2
x2 = x1
y1 = Selection.Cells(1).Top
cnt = Selection.Rows.Count
y2 = Selection.Cells(cnt).Top + Selection.Cells(cnt).Height 'down

Set Obj = ActiveSheet.Shapes.AddLine(x1, y1, x2, y2)
With Obj.Line
  .Weight = 3
  .EndArrowheadStyle = msoArrowheadTriangle
  .EndArrowheadLength = msoArrowheadLengthMedium
  .EndArrowheadWidth = msoArrowheadWidthMedium
End With
End Sub

 
4, 세로 화살표 선 (위 방향)

Sub kcDrawVLine_reverse()
Dim Obj As Shape

x1 = Selection.Cells(1).Left + Selection.Cells(1).Width / 2
x2 = x1
y1 = Selection.Cells(1).Top
cnt = Selection.Rows.Count

y2 = Selection.Cells(cnt).Top + Selection.Cells(cnt).Height 'down
Set Obj = ActiveSheet.Shapes.AddLine(x2, y2, x1, y1)
With Obj.Line
  .Weight = 3
  .EndArrowheadStyle = msoArrowheadTriangle
  .EndArrowheadLength = msoArrowheadLengthMedium
  .EndArrowheadWidth = msoArrowheadWidthMedium
End With
End Sub
Posted by Weneedu
,


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