Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

ListRanges Enumeration

Specifies the range of a ListObject that has changes.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public enum ListRanges

 Member nameDescription
DataBodyRangeThe change occurred in the DataBodyRange of the ListObject
HeaderRowRangeThe change occurred in the HeaderRowRange of the ListObject
NoneThe change did not occur in the DataBodyRange, HeaderRowRange, or TotalsRowRange
TotalsRowRangeThe change occurred in the TotalsRowRange of the ListObject

The ListRanges enumeration is used by one of the parameters of the ListObjectChangeHandler delegate.

The following code example creates a ListObject and an event handler for the Change event. The event handler uses the ListRanges values to display the location of a changed range. To raise the Change event, add text to one of the cells in the ListObject and then press ENTER.

private void ListObject_Change()
    Microsoft.Office.Tools.Excel.ListObject list1 = 
        this.Range["A1", "C4"], "list1");
    list1.Change += new Microsoft.Office.Tools.Excel.

void list1_Change(Microsoft.Office.Interop.Excel.Range 
    targetRange, Microsoft.Office.Tools.Excel.ListRanges 
    string cellAddress = targetRange.get_Address(
        missing, missing, Excel.XlReferenceStyle.xlA1, 
        missing, missing);

    switch (changedRanges)
        case Microsoft.Office.Tools.Excel.ListRanges.DataBodyRange:
            MessageBox.Show("The cells at range " + cellAddress +
                " in the data body changed.");
        case Microsoft.Office.Tools.Excel.ListRanges.HeaderRowRange:
            MessageBox.Show("The cells at range " + cellAddress +
                " in the header row changed.");
        case Microsoft.Office.Tools.Excel.ListRanges.TotalsRowRange:
            MessageBox.Show("The cells at range " + cellAddress +
                " in the totals row changed.");
            MessageBox.Show("The cells at range " + cellAddress +
                " changed.");

© 2015 Microsoft