Worksheet.Columns Property

 

Gets a Range object that represents one or more columns on the worksheet.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Range Columns { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Range

A Range object that represents one or more columns on the worksheet.

When used without parameters, this property returns a Range object that contains all the columns on the worksheet.

This property can be used with the following optional parameters to get specific columns on the worksheet. If you use this property with parameters, the return value is an object that must be cast to a Range.

Parameter

Description

RowIndex

The index of one or more columns to get.

To get a single column, pass one of the following objects to this parameter:

  • An integer that specifies the index of the column you want to get. The column indexes begin at 1.

  • A string that consists of the letter of the column you want to get.

To get multiple contiguous columns, pass a string with the format "first column letter:last column letter". For example, to get columns A through E, pass "A:E".

System_CAPS_noteNote

The name of this parameter is misleading; this parameter specifies the indexes of the columns you want to get, not the rows.

ColumnIndex

Do not use this parameter. This property will throw a COMException if you try to pass a value to this parameter.

Return to top
Show: