|
Sub Add_MyLines()
Dim xP1 As Single, yP1 As Single
Dim xP2 As Single, yP2 As Single
Dim yP3 As Single, yP4 As Single
If TypeName(Selection) <> "Range" Then Exit Sub
With Selection
If .Rows.Count <> 3 Or .Columns.Count <> 2 Then
MsgBox "3列×2行のセル範囲を選択して下さい", 48
Exit Sub
End If
xP1 = .Left: yP1 = .Top: xP2 = xP1 + .Width
yP2 = .Range("C4").Top: yP3 = .Range("A4").Top
yP4 = .Range("B2").Top
End With
With ActiveSheet.Lines
.Add xP1, yP1, xP2, yP2
.Add xP1, yP3, xP2, yP4
End With
End Sub
で、どうかな ?
3列×2行のセル範囲なら、どこでもその配置形態で直線を引けます。
|
|