Nanogirl21
Active Member
- Joined
- Nov 19, 2013
- Messages
- 330
- Office Version
- 365
- Platform
- Windows
I am using the below VBA code to apply a border around cells. Right now it is only applying the border to columns A-J. What do I need to adjust to make the border expand to column K?
VBA Code:
Sub BorderIt()
Dim Cel As Range, rng As Range, r As Long, a As Variant
For r = 1 To Range("A" & Rows.Count).End(xlUp).Row
Set Cel = Cells(r, 1)
If Cel.MergeCells Then
Set rng = Cel.MergeArea
r = Split(Cel.MergeArea.Address, "$")(4)
Else
Set rng = Cel
End If
For Each a In Array(rng, rng.Resize(, 10))
a.BorderAround , Weight:=xlMedium
Next a
Next r
End Sub