Forecast function in Excel VBA

Posted on 2007-10-19
Last Modified: 2012-08-14
I would to use the FORECAST function in excel VBA.  I have a spreadsheet called "Sheet1" that has the information I need.  Forecast requires X, known_y's, known_x's   So for X Sheet1 has cell D7 that contains this value.  For known_y's Sheet1 has E3 to E4 for this.  And known_x's has E7 to E8.  Can someone show me how to code this in VBA?

Question by:JoshinHtown
    LVL 92

    Accepted Solution

    Debug.Print Application.Forecast([d7], [e3:e4], [e7:e8])

    BTW, basing your forecast off of just two data points is incredibly risky, no?

    Author Comment

    Yes it is.  I'm just trying to get an idea as to how to call that particular function in vba is all.  Thanks

    Author Comment

    Oh I forgot to mention.  I'm going to store the outcome in a textbox so would it be Textbox1 = application.forecast([d7], [e3:e4], [e7:e8]) ?  and how does it know to point to Sheet1 for this?
    LVL 92

    Expert Comment

    by:Patrick Matthews
    Assuming you set a variable of type Worksheet...

    Textbox1 = application.forecast(ws.[d7], ws.[e3:e4], ws.[e7:e8])

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    A short article about a problem I had getting the GPS LocationListener working.
    This is an explanation of a simple data model to help parse a JSON feed
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now