Menuへ
罫線を引く

格子の罫線の場合は、下の「格子 細線」を使えば一回でできますが、それ以外は個別に引くようになります。
例えば、格子の四角でも外枠を太線にしたい場合は、上下左右をそれぞれ引く必要があります。
線種・太さをそれぞれ指定できますので、手動と同じように作成できます。




線種・太さ
■線種
xlContinuous 直線
xlDouble 二重線
xlDot 点線
xlDash 鎖線
xlDashDot 一点鎖線
xlDashDotDot 二点鎖線
xlSlantDashDot 斜め模様の一点鎖線
xlLineStyleNone 線なし

■太さ
xlHairline 極細線
xlThin 細線
xlMedium 中太線
xlThick 太線

コマンドボタン と シートプロシージャ
'格子 細線
Private Sub DoKousiKeisen(srange As String)
    Range(srange).Select

    Selection.Borders.Weight = xlThin
    Selection.Borders.LineStyle = xlContinuous
End Sub

'外枠 太線
Private Sub DoWakuKeisen(srange As String)
    Range(srange).Select
   
    '左罫線
    With Selection.Borders(xlEdgeLeft)
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
    '上罫線
    With Selection.Borders(xlEdgeTop)
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
    '右罫線
    With Selection.Borders(xlEdgeRight)
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
    '下罫線
    With Selection.Borders(xlEdgeBottom)
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
End Sub

Private Sub CommandButton1_Click()
    DoKousiKeisen "E2:G6"
    DoWakuKeisen "E2:G2"
    DoWakuKeisen "E2:G6"
    Range("A1").Select
End Sub

実行結果
罫線が表示された



Topへ Homeへ