Share via


Heading Object

Window
Headings
Heading
Window

Represents a single row or column header in the specified window's Headings collection.

Using the Heading object

Use the Headings collection's Item property to return an individual Heading object. This can be expressed as Headings(Index) or Headings.Item(Index), where Index is the index number of the individual Heading object.

Use the Caption property to customize the row and column headings in a window. The following example illustrates how to use the Caption property to change the row and column heading in a window:

Sub Change_Headings()

    Dim hdrColHeadings
    Dim hdrRowHeadings

    ' Set a variable to the column headings in the active window.
    Set hdrColHeadings = Spreadsheet1.ActiveWindow.ColumnHeadings

    ' Set a variable to the row headings in the active window.
    Set hdrRowHeadings = Spreadsheet1.ActiveWindow.RowHeadings

    ' Set the headings of columns A through D.
    hdrColHeadings(1).Caption = "Qtr 1"
    hdrColHeadings(2).Caption = "Qtr 2"
    hdrColHeadings(3).Caption = "Qtr 3"
    hdrColHeadings(4).Caption = "Qtr 4"

    ' Set the headings of rows 1 though 5.
    hdrRowHeadings(1).Caption = "Sedan"
    hdrRowHeadings(2).Caption = "Convertible"
    hdrRowHeadings(3).Caption = "Truck"
    hdrRowHeadings(4).Caption = "Sport-Utility"
    hdrRowHeadings(5).Caption = "Minivan"

End Sub

The Caption property of the Heading object is limited to 256 characters, and the text cannot be wrapped to a second line.

Use the ResetHeadings method to set the row and column headings back to their default values.

Properties | Application Property | Caption Property | Index Property | Parent Property

Methods | Reset Method

Parent Objects | Window

Child Objects | Window