ListObject.DataBodyRange Property

Gets a Range that represents the range that contains the data area in the list between the header row and the insert row.

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

Syntax

'Declaration
ReadOnly Property DataBodyRange As Range
Range DataBodyRange { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Range
A Range that represents the range that contains the data area in the list between the header row and the insert row.

Remarks

If the ListObject control does not have a DataBodyRange, this property returns nulla null reference (Nothing in Visual Basic).

Examples

The following code example creates a ListObject and then shows the number of rows that are available for data.

This example is for a document-level customization.

Private Sub ListObject_DataBodyRange()
        Dim List1 As Microsoft.Office.Tools.Excel.ListObject = _
            Me.Controls.AddListObject(Me.Range("A1", "C4"), "List1")
        Dim List1BodyRange As Excel.Range = List1.DataBodyRange
        Dim numberOfRows As Integer = List1BodyRange.Rows.Count
        MessageBox.Show("The DataBodyRange of list1 has " & _
            numberOfRows.ToString() & " rows.")

    End Sub
private void ListObject_DataBodyRange()
{
    Microsoft.Office.Tools.Excel.ListObject list1 = 
        this.Controls.AddListObject(
        this.Range["A1", "C4"], "list1");
    Excel.Range list1BodyRange = list1.DataBodyRange;
    int numberOfRows = list1BodyRange.Rows.Count;
    MessageBox.Show("The DataBodyRange of list1 has " +
        numberOfRows.ToString() + " rows.");
}

.NET Framework Security

See Also

Reference

ListObject Interface

Microsoft.Office.Tools.Excel Namespace