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.


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 with

Tough I belive this would also work.

Range(“A1:R780").Borders.LineStyle = xlContinuous 
  • Thanks I actually found a much more complex way of doing it.... probably 10 minutes before you answered... just now checked to see if there was an easier way... I basically had 6 Commands to do the same basic thing. The second one didn't work, but the with Range did work. – Crazyd Mar 18 '16 at 15:59

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"))


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.