Top Property

Applies To

Application Object, Arc Object, Arcs Collection, AxisTitle Object, Button Object, Buttons Collection, ChartArea Object, ChartObject Object, ChartObjects Collection, ChartTitle Object, CheckBox Object, DataLabel Object, DialogFrame Object, Drawing Object, DrawingObjects Collection, Drawings Collection, DropDown Object, DropDowns Collection, EditBox Object, EditBoxes Collection, GroupBox Object, GroupBoxes Collection, GroupObject Object, GroupObjects Collection, Label Object, Labels Collection, Legend Object, Line Object, Lines Collection, ListBox Object, ListBoxes Collection, OLEObject Object, OLEObjects Collection, OptionButton Object, OptionButtons Collection, Oval Object, Ovals Collection, Picture Object, Pictures Collection, PlotArea Object, Range Object, Rectangle Object, Rectangles Collection, ScrollBar Object, ScrollBars Collection, Spinner Object, Spinners Collection, TextBox Object, TextBoxes Collection, Toolbar Object, Window Object.

Description

Returns or sets the position of the specified object, in points (1/72 inch). Read-write, except for the Range object.

Remarks

The Top property has several different meanings, depending on the object to which it is applied.

Object

Meaning

Application

The distance from the top edge of the physical screen to the top edge of the main Microsoft Excel window, in points. In Windows, if the application window is minimized, this property controls the position of the icon (anywhere on the screen). On the Apple Macintosh the value is always zero; setting the value to something else will have no effect.

Button

The top position of the object, in points, measured from the top of row 1.

Range

The distance from the top edge of row one to the top edge of the range, in points. If the range is discontinuous, the first area is used. If the range is more than one row high, the top (lowest numbered) row in the range is used. Read-only.

Toolbar

If the toolbar is docked (the Position property of the Toolbar object is not xlFloating), the number of points from the top edge of the toolbar to the top edge of the toolbar docking area. If the toolbar is floating, the number of points from the top edge of the toolbar to the top edge of the Microsoft Excel workspace.


Object

Meaning

Window

The top position of the window, in points, measured from the top edge of the usable area (below the menus, top-docked toolbars, and/or the formula bar). You cannot set this property for a maximized window. Use the WindowState property to return or set the state of the window.

Arc, AxisTitle, ChartArea, ChartTitle, CheckBox, DataLabel, DialogFrame, Drawing, DrawingObjects, DropDown, EditBox, GroupBox, GroupObject, Label, Legend, Line, ListBox, OLEObject, OptionButton, Oval, Picture, PlotArea, Rectangle, ScrollBar, Spinner, TextBox, Title

The top position of the object, in points, measured from the top of row one (on a worksheet) or the top of the chart area (on a chart).


See Also

Height Property, Left Property, Width Property.

Example

This example moves oval one on Sheet1 so that it is aligned with the top edge of row 4.


Worksheets("Sheet1").Ovals(1).Top = _
    Worksheets("Sheet1").Rows(4).Top

This example aligns the top of every button on Sheet1 with the top of row 2.


topEdge = Worksheets("Sheet1").Rows(2).Top
For Each b In Worksheets("Sheet1").Buttons
    b.Top = topEdge
Next b

This example expands the active window to the maximum size available (assuming that the window is not already maximized).


With ActiveWindow
    .WindowState = xlNormal
    .Top = 1
    .Left = 1
    .Height = Application.UsableHeight
    .Width = Application.UsableWidth
End With