Results 1 to 2 of 2

Adding borders to dynamic tables

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    London, England
    MS-Off Ver
    Excel XP
    Posts
    174

    Adding borders to dynamic tables

    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
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1