Add borders (lines) around a cell range in an Excel Workbook

Dim xl As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet

Public Sub BoxesExample()

  Set ap = Application
  Set wb = ThisWorkbook
  Set ws = wb.Sheets(1)
  ws.Select

  Set rg = ws.Range(Cells(1, 1), Cells(4, 4))
  BoxCells
  Set rg = Nothing

  Set rg = ws.Range(Cells(6, 1), Cells(8, 4))
  Boxit
  Set rg = Nothing

End Sub


Public Sub Boxit()

  BoxCells
  rg.Borders(xlInsideVertical).LineStyle = xlNone
  rg.Borders(xlInsideHorizontal).LineStyle = xlNone

End Sub


Public Sub BoxCells()

  rg.Borders.LineStyle = xlNone
  rg.Borders.LineStyle = xlNone
  rg.Borders.Color = RGB(0, 0, 0)
  rg.Borders.Weight = xlMedium
  rg.Borders.LineStyle = xlContinuous

End Sub