Chart.SetSourceData method (Word)

Sets the source data range for the chart.

Syntax

expression.SetSourceData (Source, PlotBy)

expression A variable that represents a Chart object.

Parameters

Name Required/Optional Data type Description
Source Required String The address of the chart data range that contains the source data.
PlotBy Optional Variant Specifies the way the data will be plotted. Can be either of the following XlRowCol constants: xlColumns or xlRows.

Example

The following example sets the source data range for the first chart in the active document.

With ActiveDocument.InlineShapes(1) 
 If .HasChart Then 
 .Chart.SetSourceData _ 
 Source:="='Sheet1'!$A$1:$D$5", _ 
 PlotBy:=xlColumns 
 End If 
End With

See also

Chart Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.