Columns Property

Microsoft Office Web Components Object Model

Show All

Columns Property

       

Column property as it applies to the Range object.

Returns a Range object that represents the columns in the specified range. Read-only.

expression.Columns

expression   Required. An expression that returns a Range object.

Column property as it applies to the Spreadsheet and Worksheet objects.

Returns a Range object that represents all the columns on the specified worksheet.

expression.Columns

expression   Required. An expression that returns one of the above objects. Read-only.

Example

As it applies to the Range object.

This example sets the font to bold in every other column in the visible range on the active worksheet.

Sub BoldColumns() 
    Dim col 
 
    For Each col In Spreadsheet1.ActiveSheet.VisibleRange.Columns 
 
        If col.Column Mod 2 = 0 Then col.Font.Bold = True 
 
    Next 
End Sub

As it applies to the Worksheet object.

This example deletes all data from column B on the active worksheet.

Spreadsheet1.ActiveSheet.Columns(2).ClearContents