I have and Excel spread sheet that has cells that containing the following values:
Known Y Known X
2 6
3 5
9 11
1 7
8 5

In a cell I use the INTERCEPT function which Calculates the point at which a line will intersect the y-axes by using a best fit regression line plotted through the known x-values and y-values.

I need to do this in VB6 can you update the code below so that it will calculate the line of Intercept?

When it works correctly the Intercept value should equal 0.048387

Thanks

Public Function Intercept() As Double Dim KnownY(1 To 5) As Double Dim KnownX(1 To 5) As Double KnownY(1) = 2 KnownY(2) = 3 KnownY(3) = 9 KnownY(4) = 1 KnownY(5) = 8 KnownX(1) = 6 KnownX(2) = 5 KnownX(3) = 11 KnownX(4) = 7 KnownX(5) = 5 Intercept =End Function

I don't know if you can import the functions into regular VB, so here is the math solution for you following excel's explanation for the intercept function. You could also make it so it takes larger fields

I don't know if you can import the functions into regular VB, so here is the math solution for you following excel's explanation for the intercept function. You could also make it so it takes larger fields (more than 5 knowns) but this will do for your example:

Public Function Intercept() As Double

Dim KnownY(1 To 5) As Double
Dim KnownX(1 To 5) As Double
Intercept = 0

This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.

0

Featured Post

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Workbook link problems after copying tabs to a new workbook?
David Miller (dlmille)
Intro
Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.

The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210 (2 * 3 * 5 * 7) or 2310 (2 * 3 * 5 * 7 * 11).
The larger templa…