ListObject.Resize Method

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

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Syntax

'Declaration
Sub Resize ( _
    Range As Range _
)
void Resize(
    Range Range
)

Parameters

  • Range
    Type: Range

    The new range for the list.

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.

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 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
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"]);
    }
}

.NET Framework Security

See Also

Reference

ListObject Interface

Microsoft.Office.Tools.Excel Namespace