WorksheetBase.Next Property

Definition

Gets a Worksheet that represents the next sheet.

public:
 property System::Object ^ Next { System::Object ^ get(); };
public object Next { get; }
member this.Next : obj
Public ReadOnly Property Next As Object

Property Value

A Worksheet that represents the next sheet; null if the current worksheet is the last sheet in the workbook.

Examples

The following code example uses the Next property to determine whether the current WorksheetBase is the last sheet in the workbook. If the current WorksheetBase is not the last sheet, then the name of the next sheet is displayed.

This example is for a document-level customization.

private void DisplayNextWorksheet()
{
    if (this.Next != null)
    {
        Excel.Worksheet nextSheet = (Excel.Worksheet)this.Next;
        MessageBox.Show("The next worksheet is " + nextSheet.Name);
    }
    else
    {
        MessageBox.Show("This worksheet is the last worksheet.");
    }
}
Private Sub DisplayNextWorksheet()
    If Not (Me.Next Is Nothing) Then
        Dim nextSheet As Excel.Worksheet = _
            CType(Me.Next, Excel.Worksheet)
        MsgBox("The next worksheet is " & nextSheet.Name)
    Else
        MsgBox("This worksheet is the last worksheet.")
    End If
End Sub

Applies to