Add a column to the end of a Table

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
I have a table [PQ_Material_Assoc_Costs] on a sheet named PQ Material Assoc Costs
The table headers are in Row 1 (Starting in A)

The table is dynamic so i dont know in advance how many columns there will be.

How can I find what is the last column in my table and then add these two "fields"?

(This is using Y and Z but as stated, i dont know what column will be the last one and where to add these so that they are add and are the last two)
Sheets("PT Material Assoc Costs").Range("Y1") = "Mtrl Consolidation"
Sheets("PT Material Assoc Costs").Range("Z1") = "Vendor Name"


Thank you for your help
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Assuming your sheet name is PQ Material Assoc Costs as described in the first line and not PT Material Assoc Costs as implied in these statements:

Sheets("PT Material Assoc Costs").Range("Y1") = "Mtrl Consolidation"
Sheets("PT Material Assoc Costs").Range("Z1") = "Vendor Name"

try:

VBA Code:
    With Sheets("PQ Material Assoc Costs").ListObjects("PQ_Material_Assoc_Costs").HeaderRowRange
        With .Offset(0, .Count).Resize(1, 2)
            .Value = Array("Mtrl Consolidation", "Vendor Name")
            .EntireColumn.AutoFit
        End With
    End With
 
Upvote 0
Solution

Forum statistics

Threads
1,215,352
Messages
6,124,453
Members
449,161
Latest member
NHOJ

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