Delete entire column in Excel using VSTO C# Addin

Delete entire column in Excel using VSTO C# Addin


It returns a range object which indicates one or more columns within specified range. EntireColumn object exposes Delete() method which deletes the column in Excel. The Delete method takes optional argument derives through “xlDeleteShiftDirection” which has two constants:

  • xlShiftToRight
  • xlShiftUp (Default)


  • Visual Studio 2015 or above having Microsoft Office for Developer Tool installed
  • Create Excel Addin in C# code style
  • Create a ribbon designer and put button

Code example:

private void btnDeleteColumn_Click(object sender, RibbonControlEventArgs e)
	//capture user selection
	excel.Range oRange = Globals.ThisAddIn.Application.Selection;
	//delete entire row

Let’s see before and after code execution output.

Before code execution output:

Post code execution:

If you notice above example screenshot the Column-1 has been removed from my range. Please leave your valuable comments!!!

Next : Delete worksheet in Excel Addin using C# VSTO

Leave a Reply

Your email address will not be published. Required fields are marked *