Udostępnij za pośrednictwem


ListObject.Resize(Range) Method

Definition

Enables a ListObject control to be resized over a new range.

public:
 void Resize(Microsoft::Office::Interop::Excel::Range ^ Range);
public void Resize (Microsoft.Office.Interop.Excel.Range Range);
abstract member Resize : Microsoft.Office.Interop.Excel.Range -> unit
Public Sub Resize (Range As Range)

Parameters

Range
Range

The new range for the list.

Examples

The following code example creates a ListObject on the current worksheet and then calls the Resize method to increase the size of the ListObject.

This example is for a document-level customization.

private void ListObject_Resize()
{
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(this.Range["A1", "D4"], "list1");

    if (DialogResult.Yes == MessageBox.Show("Resize the ListObject?",
        "Test", MessageBoxButtons.YesNo))
    {
        list1.Resize(this.Range["A1", "H4"]);
    }
}
Private Sub ListObject_Resize()
    Dim List1 As Microsoft.Office.Tools.Excel.ListObject = _
        Me.Controls.AddListObject(Me.Range("A1", "D4"), "List1")

    If DialogResult.Yes = MessageBox.Show("Resize the ListObject?", _
        "Test", MessageBoxButtons.YesNo) Then
        List1.Resize(Me.Range("A1", "H4"))
    End If

End Sub

Remarks

No cells are inserted or moved by this property.

The header must remain in the same row and the resulting list must overlap the original list. The list must contain a header row and at least one row of data.

For lists that are linked to a server that is running Microsoft Windows SharePoint Services, you can resize the list using this method by providing a Range argument that differs from the current range of the ListObject only in the number of rows it contains. Attempting to resize lists linked to Windows SharePoint Services by adding or deleting columns (in the Range argument) results in a run-time error.

Applies to