雑多なルーチン

Option Explicit

' 大項目、中項目、小項目形式で書かれた表の罫線を綺麗に整理する
' 空白のセルは罫線を引かないように整理する
Sub FormatRuledLine()
    For Each c In Selection
        c.Borders.LineStyle = xlContinuous
        If c.Value = "" Then
            c.Borders(xlEdgeTop).LineStyle = xlLineStyleNone
            c.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone
        End If
    Next c
End Sub

' 枠線表示のトグル
Sub ToggleGridLines()
    If ActiveWindow.DisplayGridlines = True Then
        ActiveWindow.DisplayGridlines = False
    Else
        ActiveWindow.DisplayGridlines = True
    End If
End Sub

' 文章の最後に空行を追加する
' アセスメントなどでの対策
Sub InsertNewline()
    For Each c In Selection
        If Right(Trim(c.Value), 1) <> Chr(10) Then
            c.Value = c.Value & Chr(10)
        End If
    Next c
End Sub

' 最後の行を取得する
Function GetLastRow(ByVal strColName As String)
    GetLastRow = ActiveWorkbook.ActiveSheet.Range(strColName & "65536").End(xlUp).Row
End Function