How to Delete a Column Programmatically?

Aximili picture Aximili · Aug 19, 2010 · Viewed 26.4k times · Source

How does one delete a column (or multiple columns) in Excel?

eg. How to delete column C and shift the rest left?

Answer

Aximili picture Aximili · Aug 19, 2010

Here is the solution to make it clearer (thanks to Leniel for the link)

Excel.Range range = (Excel.Range)sheet.get_Range("C1", Missing.Value);
range.EntireColumn.Delete(Missing.Value);
System.Runtime.InteropServices.Marshal.ReleaseComObject(range);