Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a new column to an existing sheet and name it?

Tags:

Suppose I have the worksheet below:

Empid  EmpName  Sal 1      david     100 2      jhon      200 3      steve     300 

How can I insert a new column named "Loc"?

Empid  EmpName   Loc   Sal  1      david     uk    100 2      jhon      us    200 3      steve     nj    300 
like image 276
Raj Avatar asked Oct 11 '11 15:10

Raj


People also ask

How do I add a column to an existing worksheet in Excel?

To insert a single column: Right-click the whole column to the right of where you want to add the new column, and then select Insert Columns. To insert multiple columns: Select the same number of columns to the right of where you want to add new ones. Right-click the selection, and then select Insert Columns.

How do I add a column to a sheet?

On your computer, open a spreadsheet in Google Sheets. Select a row, column, or cell. Right-click the row, column, or cell. From the menu that appears, select Insert 1 left, right, above or below.

How do you name a new column in Excel?

Click the letter of the column you want to change and then the "Formulas" or "General" on your computer. Select "Define Name" under the Defined Names group in the Ribbon to open the New Name window. Enter your new column name in the text box.

How do I add a column name in VBA?

To insert a column using a VBA code, you need to use the “Entire Column” property with the “Insert” method. With the entire column property, you can refer to the entire column using a cell and then insert a new column. By default, it will insert a column before the cell that you have mentioned.


1 Answers

Use insert method from range, for example

Sub InsertColumn()         Columns("C:C").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove         Range("C1").Value = "Loc" End Sub 
like image 140
Bruno Leite Avatar answered Oct 24 '22 16:10

Bruno Leite