Cell Property

Microsoft Office Web Components Object Model

Cell Property

       

Returns a PivotCell object that indicates the location of the aggregate cell or detail cell. Use this property to return more information about the selected area in a PivotTable list.

expression.Cell

expression   Required. An expression that returns one of the objects in the Applies To list.

Example

This example utilizes the DoubleClick event of PivotTable1 to display more information about a cell in the detail area of the PivotTable. This example assumes that PivotTable1 is using the Customers table form the Northwind database.

Sub PivotTable1_DblClick()
    Dim ptSelection
    Dim nRow
    Dim rs

    Set ptSelection = PivotTable1.Selection

    ' If the current selection is in the
    ' detail area of the PivotTable list.
    If TypeName(ptSelection) = "PivotDetailRange" then

        nRow = ptSelection.TopLeft.Row

        ' Set a variable to the recordset of the top-left
        ' cell in the selection.
        Set rs = ptSelection.TopLeft.Cell.Recordset

        ' Move the cursor the the correct record in the recordset.
        rs.Move nRow

        MsgBox "The row that was double-clicked was..." & String(2, vbCrLf) & _
            "Customer ID = " & rs("CustomerID") & vbCrLf & _
            "Company Name = " & rs("CompanyName") & vbCrLf & _
            "Contact Name = " & rs("ContactName")
    Else
        MsgBox "Double-click on a row!", vbExclamation
    End If

End Sub