Editing a specific column in a table only using the position(sequence) of the column

yxz152830

Active Member
Joined
Oct 6, 2021
Messages
393
Office Version
  1. 365
Platform
  1. Windows
Gurus, this is a 3 part question, please bear with me.
1. I have a table with 13 columns but if I insert a new column in between 2 columns. It gives me really random header names like "column 62", "column 51" etc. Isn't it supposed to be "column 14"?

2. Anyways thats not so important because im gonna change the name of the header regardless. The thing is that I only know ------
ActiveWorkbook.Sheets("").ListObjects("").ListColumns("Column name").Name = "New column name" , to change the name of the header. Now that I only know the relative position of the column. How do I do it?
VBA Code:
Selection.ListObject.ListColumns.Add Position:=7

3. how do I pass down a formula to the whole column? This is what i recorded:
ActiveCell.FormulaR1C1 = _
"=[@Column6]+TIME(,VLOOKUP([@Column3],flight_arrival_adjust,2,0),)"
i think i only need to change the left side as right side contains a passing down formula but not sure how.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
How about
VBA Code:
Sub yxz()
   With Sheets("abc").ListObjects("Table1")
      .ListColumns.Add 7
      .ListColumns(7).Name = "Test"
      .ListColumns(7).DataBodyRange.FormulaR1C1 = "=[@Column6]+TIME(,VLOOKUP([@Column3],flight_arrival_adjust,2,0),)"
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,678
Members
449,116
Latest member
HypnoFant

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