Diagram Property

Microsoft Excel Visual Basic

Diagram Property

       

Returns a Diagram object representing a diagram.

expression.Diagram

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

Example

In this example, an Organization chart diagram is added to the active worksheet. Microsoft Excel then displays a message with the number of nodes added to the diagram.

Sub UseDiagram()

    Dim wksOne As Worksheet
    Set wksOne = ActiveSheet

    ActiveSheet.Shapes.AddDiagram( _
        Type:=msoDiagramOrgChart, Top:=10, _
        Left:=15, Width:=400, Height:=475)

    'Notify user the number of nodes added to the diagram.
    MsgBox wksOne.Shapes(1).Diagram.Nodes.Count

End Sub