User Tools

Site Tools


microsoft_excel:macros:insert:insert_column

Microsoft Excel - Macros - Insert - Insert Column

Sub InsertColumns()
'PURPOSE: Insert column(s) into the active worksheet
'SOURCE: www.TheSpreadsheetGuru.com

'Insert Column to the left of Column F
  Columns("E:E").Insert Shift:=xlToRight, _
    CopyOrigin:=xlFormatFromRightOrBelow
    Range("E1").Value = "CELL1_NO"
    Range("E:E").Interior.Color = xlNone

'Insert Column to the left of Column K
  Columns("J:J").Insert Shift:=xlToRight, _
    CopyOrigin:=xlFormatFromRightOrBelow
    Range("J1").Value = "CELL2_NO"
    Range("J:J").Interior.Color = xlNone

'Insert Column to the left of Column P
  Columns("O:O").Insert Shift:=xlToRight, _
    CopyOrigin:=xlFormatFromRightOrBelow
    Range("O1").Value = "CELL3_NO"
    Range("O:O").Interior.Color = xlNone
    
'Insert Column to the left of Column K
  Columns("S:S").Insert Shift:=xlToRight, _
    CopyOrigin:=xlFormatFromRightOrBelow
    Range("S1").Value = "CELL4_NO"
    Range("S:S").Interior.Color = xlNone
    
'Insert Column to the left of Column K
  Columns("W:W").Insert Shift:=xlToRight, _
    CopyOrigin:=xlFormatFromRightOrBelow
    Range("W1").Value = "CELL5_NO"
    Range("W:W").Interior.Color = xlNone
    
'Insert Column to the left of Column K
  Columns("Z:Z").Insert Shift:=xlToRight, _
    CopyOrigin:=xlFormatFromRightOrBelow
    Range("Z1").Value = "CELL6_NO"
    Range("Z:Z").Interior.Color = xlNone
    
'Insert Column to the left of Column K
  Columns("AB:AB").Insert Shift:=xlToRight, _
    CopyOrigin:=xlFormatFromRightOrBelow
    Range("AB1").Value = "CELL7_NO"
    Range("AB:AB").Interior.Color = xlNone
End Sub
microsoft_excel/macros/insert/insert_column.txt · Last modified: 2021/08/04 15:05 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki