Freigeben über


NamedRange.Previous Property

Definition

Gets a Range that represents the previous cell.

public:
 property Microsoft::Office::Interop::Excel::Range ^ Previous { Microsoft::Office::Interop::Excel::Range ^ get(); };
public Microsoft.Office.Interop.Excel.Range Previous { get; }
member this.Previous : Microsoft.Office.Interop.Excel.Range
Public ReadOnly Property Previous As Range

Property Value

A Range that represents the previous cell.

Examples

The following code example creates a NamedRange and then uses the Previous property to select the cell to the left of the NamedRange.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange previousRange;
private void SelectPrevious()
{
    previousRange = this.Controls.AddNamedRange(
         this.Range["C1"], "prefixRange");
    this.previousRange.Previous.Select();
}
Private previousRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub SelectPrevious()
    previousRange = Me.Controls.AddNamedRange( _
        Me.Range("C1"), "prefixRange")
    Me.previousRange.Previous.Select()
End Sub

Remarks

This property emulates pressing SHIFT+TAB; unlike the key combination, however, the property returns the previous cell without selecting it.

On a protected sheet, this property returns the previous unlocked cell. On an unprotected sheet, this property always returns the cell immediately to the left of the specified cell.

Applies to