Putting a border on my new column in my table

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,392
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a spreadsheet that I have to record new data in every week. This spreadsheet has a table in it, which is one of the new features of excel, being able to put a table in. I have some code that will insert a new column so I can enter the data for the current week.

What I want is to be able to put a border around that new column that is added.

The table name is tblQuals and the code that I have for the new row is below.
VBA Code:
    Columns("D:D").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("D8").Select
    ActiveCell.FormulaR1C1 = "As of " & Date
    ActiveCell.Font.size = 11
    
    Columns("D:D").ColumnWidth = 18.71
    With Range("E6")
        .Copy Range("D6")
        .Clear
    End With
    
    Columns("E:E").Validation.Delete

Thanks
 
See if this is more like it. If not, please make sure we can see the column letters in any further images.

VBA Code:
Sub Test_v2()
  With ActiveSheet.ListObjects("tblQuals")
    .ListColumns.Add Position:=4
    With .ListColumns(4).Range
      .Resize(, 2).ColumnWidth = 18.71
      .Cells(1).Value = "As of " & Date
      .Cells(1).Font.Size = 11
      .Offset(, 1).Borders.LineStyle = xlLineStyleNone
      .BorderAround xlContinuous, xlThick, xlAutomatic
    End With
  End With
End Sub
 
Last edited:
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top