Hi I'm trying to add in borders to a set of dynamic tables. I've attached a file that has 3 tables, I've displayed the borders on the first one (desired outcome). As the number of rows of the table can change everytime I need a code for this.
I need to add a 'Borders' code to the following piece of existing code.
Any thoughts?
Thanks!
Sub xyz()
Dim r As Range, i As Long
With Columns(4).SpecialCells(xlCellTypeConstants)
For i = 1 To .Areas.Count
Set r = .Areas(i).CurrentRegion
r(r.Rows.Count + 1, 1).Value = "TOTAL"
r(r.Rows.Count + 1, 2).Resize(, 6).Formula = "=SUM(" & r(2, 2).Address(0, 0) & ":" & r(r.Rows.Count, 2).Address(0, 0) & ")"
r(r.Rows.Count + 2, 1).Value = "Annualised"
r(r.Rows.Count + 2, 2).Resize(, 6).Formula = "=$A$2*SUM(" & r(2, 2).Address(0, 0) & ":" & r(r.Rows.Count, 2).Address(0, 0) & ")"
r(r.Rows.Count + 1, 3).Resize(, 2).ClearContents
r(r.Rows.Count + 2, 2).Resize(, 4).ClearContents
Cells(Rows.Count, 1).End(xlUp)(2).Value = r(1, 1)
Cells(Rows.Count, 2).End(xlUp)(2).Value = r(r.Rows.Count + 2, 6)
Cells(Rows.Count, 3).End(xlUp)(2).Value = r(r.Rows.Count + 2, 7)
Next i
End With
End Sub
Bookmarks