473,408 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Replicating excel function LinEst in Access VBA

What I am trying to do is to simulate the LINEST functionality from
Excel in Access through VBA.

When I use LinEst in Excel I can get back five statistical results.
Here are is the formula array I use:

Slope {=LINEST(H72:H94,I72:I94,TRUE,TRUE)}
SE {=LINEST(H72:H94,I72:I94,TRUE,TRUE)}
RSquared {=LINEST(H72:H94,I72:I94,TRUE,TRUE)}
F-Stat {=LINEST(H72:H94,I72:I94,TRUE,TRUE)}
RegSS {=LINEST(H72:H94,I72:I94,TRUE,TRUE)}

My first question is, do Excel functions exist to calculate each of
these statistics independently (not as part of the LINEST array)? So
far I have only found the equivalents for Slope and R-Squared ("=SLOPE"
and "=RSQ" respectively).

Secondly, what are the mathematical formulas that match each of these
Excel formulas? Again, I have only found the formula for slope thus
far which I can work easily into code (see snippet below).
>>>>>
strSQL = _
"SELECT Sum([x]) AS SumX, Sum([x]^2) AS SumXX, " & _
"Sum([y]) AS SumY, sum([y]^2) as SumYY, Sum([x]*[y]) AS SumXY,
Count(*) AS N " & _
"FROM data_table " & _
"WHERE ((([x]) Is Not Null) AND (([y]) Is Not Null));"

rs.Open strSQL, conn, adOpenStatic, adLockReadOnly
If rs.EOF = False Then
Slope = (rs!N * rs!SumXY - rs!SumX * rs!SumY) / (rs!N *
rs!SumYY - rs!SumY ^ 2)
b = (rs!SumYY * rs!SumX - rs!SumY * rs!SumXY) / (rs!N *
rs!SumYY - rs!SumY ^ 2)
>>>>>>>>e
For now, I'd like to set aside any debate as to whether these functions
calculate statistics accurately. What I want to do is duplicate the
Excel results I get within MS Access, and ideally without calling an
instance of Excel to do it.

Thanks in advance,
David_from_Chicago

Aug 24 '06 #1
4 10427
you should be able to use the functions if you reference the right
library in your code. and then it would be like calling your own UDF in
a query.

Aug 24 '06 #2
pietlinden wrote:
you should be able to use the functions if you reference the right
library in your code. and then it would be like calling your own UDF in
a query.
Certainly this should be one option. However, I believe the I need to
be able to calculate each LinEst statistic independently and I haven't
found these functions yet. Also, if possible, I would like to avoid
any calls to Excel to make this happen.

Any other ideas?

Aug 25 '06 #3
bump... any more input on this?

Aug 29 '06 #4
David_from_Chicago wrote:
bump... any more input on this?
The definitions you need should be found at:

http://mathworld.wolfram.com

I love these kinds of problems so post back if you have any specific
questions regarding their implementation..

James A. Fortune
CD********@FortuneJames.com

There's a universe nearby
where thought is light
and love is sound.
There is another one too,
where joy's a storm.
And others.
And in a way,
they all fit together.

Aug 30 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John | last post by:
I'd love to hear some expert opinion on my situation. My department relies on Excel as a database, which causes crashing due to resource depleting and basically is just too slow. For example, a...
11
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it...
1
by: jobxyz | last post by:
Hi I am trying to call the excel function linest from VB using automation. the call Slope1 = Excel.WorksheetFunction.Index(Excel.WorksheetFunction.LinEst(y, x),1) works fine as long as x...
1
by: Jaime Leivers | last post by:
Here's a median function in access that you can call in any query. You could change this to any excel function you wanted. Most people can find the windows help file that says how to call an excel...
5
by: joeblue | last post by:
I have the following code in Access 97: Public gobjExcel As Object Public gobjWorkSheet As Object Set gobjExcel = GetObject(, "Excel.Application") If Err.Number Then Set...
0
NeoPa
by: NeoPa | last post by:
Many of us have noticed that there are some very useful functions available to you when using Excel, but these same functions are not available, as standard, in Access. A particular issue I had...
5
ADezii
by: ADezii | last post by:
Periodically, the same or similar question appears in our Access Forum: How can I use Excel Functions within Access? For this reason, I decided to make this Subject TheScripts Tip of the Week. In...
1
by: scubasteve | last post by:
Looking up values from an Access table is simple. Simulating the 'Range Lookup' functionality from Excel's VLookup formula is a bit trickier. For those that aren't familiar with this, it allows...
1
by: Pankaj K Joshi | last post by:
Sir I have Excel function of converting figure into words, now I want to use this function in access. Now how to use it in access? I have two text box in access one is of Amount & other is of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.