Excel2000 VBA InputBoxで選択した範囲に灰色の罫線を引く [Excel2000 VBA独習]
Excel2000 VBA InputBoxで選択した範囲に灰色の罫線を引く
背景色を設定すると罫線?が見えなくなるので、新たな灰色の罫線を引くマクロ
Sub 灰色罫線()
'
'背景色を設定したセルに灰色の罫線を設定したい時に使う
'
'実験バージョン
On Error GoTo owari 'inputboxでキャンセルボタンが押された時の処理のつもり
Dim target As Range
Dim csl As Range
'InputBoxで選択範囲を取得
Set csl = Application.InputBox(Title:="灰色の罫線を引く範囲を選択してください!", prompt:="範囲選択のセルに灰色の罫線をせっていする", Type:=8)
'選択範囲セル縦罫線を設定する
For Each target In csl
target.Borders(xlDiagonalDown).LineStyle = xlNone
target.Borders(xlDiagonalUp).LineStyle = xlNone
With target.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With target.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With target.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With target.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
Next target
owari: 'キャンセルボタンが押されてのエラー処理
End Sub
コメント 0