Share via


WorksheetFunction.Forecast Method

Calculates, or predicts, a future value by using existing values. The predicted value is a y-value for a given x-value. The known values are existing x-values and y-values, and the new value is predicted by using linear regression. You can use this function to predict future sales, inventory requirements, or consumer trends.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function Forecast ( _
    Arg1 As Double, _
    Arg2 As Object, _
    Arg3 As Object _
) As Double
'Usage
Dim instance As WorksheetFunction
Dim Arg1 As Double
Dim Arg2 As Object
Dim Arg3 As Object
Dim returnValue As Double

returnValue = instance.Forecast(Arg1, _
    Arg2, Arg3)
double Forecast(
    double Arg1,
    Object Arg2,
    Object Arg3
)

Parameters

  • Arg1
    Type: System.Double

    X - the data point for which you want to predict a value.

  • Arg2
    Type: System.Object

    Known_y's - the dependent array or range of data.

  • Arg3
    Type: System.Object

    Known_x's - the independent array or range of data.

Return Value

Type: System.Double

Remarks

If x is nonnumeric, Forecast returns the #VALUE! error value.

If known_y's and known_x's are empty or contain a different number of data points, Forecast returns the #N/A error value.

If the variance of known_x's equals zero, then Forecast returns the #DIV/0! error value.

The equation for Forecast is a+bx, where:

Figure 1: Equation for the Forecast method

Equation for the Forecast method

And:

Figure 2: Equation for the Forecast method

Equation for the Forecast method

and where x and y are the sample means AVERAGE(known_x's) and AVERAGE(known y's).

See Also

Reference

WorksheetFunction Interface

WorksheetFunction Members

Microsoft.Office.Interop.Excel Namespace