I would think there is a way in VBA to put the 4 wall borders for every cell in a range, but I have yet to figure out or find one. Basically I want a range such as (A1:R780) to all have their own square.
22 Answers
I don't know a more efficient way than this.
With Range("A1:R780") .Borders(xlInsideVertical).LineStyle = xlContinuous .Borders(xlInsideHorizontal).LineStyle = xlContinuous .BorderAround xlContinuous
End withTough I belive this would also work.
Range(“A1:R780").Borders.LineStyle = xlContinuous 1 How I did it... The on error line is in case the area doesn't have Vertical or Horizontal lines. Honestly originally I didn't use BorderAround I used xlEdgeBottom, xlEdgeTop, xlEdgeLeft, xlEdgeRight.
I had to use call 5 times aka reason for making it a subroutine, plus they were dynamic.
Sample Call
Call BoxIt(Range("A1:z25"))Subroutine
Sub BoxIt(aRng As Range)
On Error Resume Next With aRng 'Clear existing .Borders.LineStyle = xlNone 'Apply new borders .BorderAround xlContinuous, xlThick, 0 With .Borders(xlInsideVertical) .LineStyle = xlContinuous .ColorIndex = 0 .Weight = xlMedium End With With .Borders(xlInsideHorizontal) .LineStyle = xlContinuous .ColorIndex = 0 .Weight = xlMedium End With End With
End Sub