VBA 斜線用のパーツ Excelリボンに登録

'選択範囲の空白とゼロ値に斜線を引く
'とりあえず、3000個分
Sub myDrawBlankDiagonalLine1()
    Dim c As Range
    Dim n As Long
    For Each c In ActiveWindow.RangeSelection
        If c.Value = "" Or c.Value = 0 Then
            c.Borders(xlDiagonalUp).Weight = xlThin
            n = n + 1
            If n = 3000 Then
                MsgBox "処理セルが3000個を超えました"
                Exit For
            End If
        End If
    Next c
End Sub


'選択範囲の斜線を消す
Sub myDelDiagonalLine()
    ActiveWindow.RangeSelection.Borders(xlDiagonalUp).LineStyle = xlNone
End Sub

コメント