+ Reply to Thread
Results 1 to 11 of 11

Unable to get the WorksheetFunction.Linest working

  1. #1
    Registered User
    Join Date
    02-24-2020
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    5

    Unable to get the WorksheetFunction.Linest working

    Hi,

    I have a problem with the linest function. I'm trying to get the Qudratic regression of a set of values and display it in a sheet. However I keep getting the error "Unable to get the linEst property of the WorksheetFunction Class". My code is:
    Please Login or Register  to view this content.
    When I use the excel formula "=LINEST($B2:$B43,$A2:$A43^{1,2})" this works fine. I just can't figure out how to do the exact same thing using the LinEst function in VBA.
    Last edited by alansidman; 02-24-2020 at 08:15 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Unable to get the WorksheetFunction.Linest working

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Unable to get the WorksheetFunction.Linest working

    $A2:$A43^{1,2} is perfectly good worksheet formula syntax that Excel can recognize, but VBA -- being a different programming language -- does not recognize this syntax. In order to do this in VBA, you will need to add another column to your Xvals -- one column for the regular X values that you already have, and a second column that will contain the X^2 values.

    With that second column, you should have no difficulty calling LINEST() from VBA.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    02-24-2020
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    5

    Re: Unable to get the WorksheetFunction.Linest working

    Thank you for your reply. I tried getting the X^2 values but I get different values to what "=LINEST($B2:$B43,$A2:$A43^{1,2})" gives. What does the "^{1,2} actually do in this case?

  5. #5
    Registered User
    Join Date
    02-24-2020
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    5

    Re: Unable to get the WorksheetFunction.Linest working

    No worries. Thank you very much

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Unable to get the WorksheetFunction.Linest working

    Why not just put the formula into the cells using code and then you can replace it with the values if you wish?
    Rory

  7. #7
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Unable to get the WorksheetFunction.Linest working

    Administrative note
    Please update your profile as necessary to properly reflect the exact version(s) of Excel your question relates to. Members tailor answers based on your Excel version. Your profile does not indicate your version.
    Thanks

  8. #8
    Registered User
    Join Date
    02-25-2020
    Location
    Yola, Nigeria
    MS-Off Ver
    2016
    Posts
    1
    Hi, I'm working on similar work here. How can i code my excel to get a linear regression model with two variables

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Unable to get the WorksheetFunction.Linest working

    @Emmy

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

  10. #10
    Registered User
    Join Date
    02-24-2020
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    5

    Re: Unable to get the WorksheetFunction.Linest working

    Rorya,
    I can do that using this:

    Please Login or Register  to view this content.
    But I also want to increment the Column reference in the Linest formula (go from B-GT while keeping the row numbers 2&43 the same) and display the correspoinding results from .Range(B[rownumberincrement]:D[rownumberincrement]. Do you know if there's a way to get around this or an easier way?
    Last edited by Sfern; 02-25-2020 at 07:50 PM.

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: Unable to get the WorksheetFunction.Linest working

    So you want to copy the formula down, but have the columns increment, not the rows?

    If so, maybe do something like this:

    Please Login or Register  to view this content.
    adjusting the 150 to however many columns that actually is.
    Last edited by rorya; 02-26-2020 at 04:46 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Unable to get WorkSheetFunction.Match to work
    By j_Southern in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-28-2019, 11:35 AM
  2. Unable to get the Sum property of the WorksheetFunction class
    By Maike in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2019, 03:09 PM
  3. [SOLVED] Unable to get worksheetFunction Class error
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-08-2017, 03:41 AM
  4. Unable to get SUM property of the worksheetfunction class
    By cmbh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-15-2016, 11:08 PM
  5. [SOLVED] Linest Function - Unable to get LinEst property of the WorksheetFunction class
    By fbs13 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-25-2013, 09:55 AM
  6. unable to use worksheetfunction XIRR in VBA
    By mtripp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2013, 05:17 PM
  7. [SOLVED] Unable to get Match property of worksheetfunction
    By Kevin Vaughn in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2006, 08:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1