Statistics [WksRange]

Statistics calculates statistics on all the columns in the range. Returns a WksStatistics object.

Syntax

object.Statistics( Sample, Header, Flags )

Parameter

Type

Required/

Optional

Default

Description

Sample

Boolean

Optional

False

This specifies whether the data represent a statistical sample or the complete set of all possible members of a population. If set to 'True', the data represent a sample.

Header

Boolean

Optional

False

This specifies whether the first row of the selection contains descriptive labels.

If this is set to 'True', the label appears at the top of the statistics report for each column.

Flags

Long

Optional

wksStatsAll

This specifies the statistics to compute, the WksStats enumeration can be used for this parameter.

Remarks

See Specifying Cell Coordinates for more information on selecting cells.

Set multiple flags by adding the enumeration names or values. For example, to calculate only the Mean, Median, and Mode of the set,

WksRange.Statistics(Flags:=wksStatsMean + wksStatsMedian + wksStatsMode)

or

WksRange.Statistics(Flags:=33555200)

will both return a WksStatistics object with Mean, Median, and Mode property values. The unspecified statistics values will be Null.

Example

This example demonstrates how to calculate only the mean for the column, and then print the mean of column A in the immediate window.

Set stats = WksRange.Statistics(Flags:=wksStatsMean)

Debug.Print stats.Mean

Used by: WksRange object