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

前端 未结 2 899
一整个雨季
一整个雨季 2021-02-12 11:50

Suppose I have the worksheet below:

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

How can I insert a new c

相关标签:
2条回答
  • 2021-02-12 12:48

    For your question as asked

    Columns(3).Insert
    Range("c1:c4") = Application.Transpose(Array("Loc", "uk", "us", "nj"))
    

    If you had a way of automatically looking up the data (ie matching uk against employer id) then you could do that in VBA

    0 讨论(0)
  • 2021-02-12 12:52

    Use insert method from range, for example

    Sub InsertColumn()
            Columns("C:C").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
            Range("C1").Value = "Loc"
    End Sub
    
    0 讨论(0)
提交回复
热议问题