Sub DrawBox()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
'定义框的起始和结束单元格
Dim startCell As Range
Dim endCell As Range
Set startCell = ws.Range("B2")
Set endCell = ws.Range("E5")
'绘制边框
With ws.Range(startCell, endCell).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 0
End With
With ws.Range(startCell, endCell).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 0
End With
With ws.Range(startCell, endCell).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 0
End With
With ws.Range(startCell, endCell).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 0
End With
End Sub