よく使う「選択したセルに罫線設定」をショートカットで処理したいので作成しました。
基本構文は・・・
With Selection.Borders(位置)
.LineStyle = xlContinuous ' 実線
.Weight = xlThin ' 太さ(細線)
.Color = RGB(0, 0, 0) ' 色(黒)
End With
太さ指定は・・・
xlHairline … 極細
xlThin … 細
xlMedium … 中
xlThick … 太
Sub 外枠だけ太線()
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
End With
End Sub
処理結果
Sub 外枠太線_内側細線()
' 外枠 太線
Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
Selection.Borders(xlEdgeLeft).Weight = xlThick
Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
Selection.Borders(xlEdgeTop).Weight = xlThick
Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
Selection.Borders(xlEdgeRight).Weight = xlThick
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).Weight = xlThick
' 内側 細線
Selection.Borders(xlInsideVertical).LineStyle = xlContinuous
Selection.Borders(xlInsideVertical).Weight = xlThin
Selection.Borders(xlInsideHorizontal).LineStyle = xlContinuous
Selection.Borders(xlInsideHorizontal).Weight = xlThin
End Sub
処理結果
Sub 全体に中線()
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlMedium
.Color = RGB(0, 0, 0)
End With
End Sub
処理結果