+ Reply to Thread
Results 1 to 5 of 5

How to make LINEST function automatically adjust to data set size...

  1. #1
    Registered User
    Join Date
    06-11-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    7

    How to make LINEST function automatically adjust to data set size...

    I have this quadratic LINEST function which analyzes a 20 year times series of free cash flows of Exxon Mobil. So the default data set size is n=20. However, many companies do not have 20 years worth of data so if I analyze a company with only 10 years of data (n=10), the LINEST function will return a #VALUE! error until I manually adjust the cell references. This is a hassle to say the least, especially when I have 10 of these LINEST functions to adjust as I don't only look at free cash flows. Below is the LINEST function as I have it now.

    How do I make this function automatically adjust to the data set size when it changes?

    {=TRANSPOSE(LINEST(B25:B44,$A$25:$A$44^{1,2}))}

    If n changes from 20 variables to just 10, assume the cell reference changes to B25:B34 and $A$25:$A$34. How do I make this happen without having to manually do it?

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: How to make LINEST function automatically adjust to data set size...

    =TRANSPOSE(LINEST(OFFSET(B25,0,0,COUNTA(B25:B44),1),OFFSET($A$25,0,0,COUNTA($A$25:$A$44),1)^{1,2}))

    though you can also extend the range if you expect more than 20 as well:

    =TRANSPOSE(LINEST(OFFSET(B25,0,0,COUNTA(B25:B1000),1),OFFSET(($A$25,0,0,COUNTA($A$25:$A$1000),1)^{1,2}))

    Just make sure you don't have extraneous data that can throw off the COUNTA function
    Last edited by Bernie Deitrick; 07-29-2014 at 01:19 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to make LINEST function automatically adjust to data set size...

    Duplicate post: http://www.excelforum.com/excel-prog...ml#post3784720

    Cross-post: http://www.mrexcel.com/forum/excel-q...-set-size.html
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    06-11-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: How to make LINEST function automatically adjust to data set size...

    Thanks Bernie.

    shg, I am looking in multiple places for the answer. Additionally, I posted in the VBA forum to see if there is VBA code that will perform this, in addition to whether I can find a simple excel formula.

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: How to make LINEST function automatically adjust to data set size...

    If you are copying this across, always using A for the year values (which don't change), then the second COUNTA needs to reference the data in column B, to balance the ranges that LINEST is given.

    =TRANSPOSE(LINEST(OFFSET(B25,0,0,COUNTA(B25:B44),1),OFFSET($A$25,0,0,COUNTA(B25:B44),1)^{1,2}))

+ 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. Replies: 2
    Last Post: 01-16-2013, 03:42 AM
  2. [SOLVED] MACRO to insert and adjust LINEST arrays
    By ad9051 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-22-2012, 12:47 PM
  3. Automatically adjust shape size based on value in a cell
    By jrv326s in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2011, 12:41 PM
  4. [SOLVED] adjust automatically size margins
    By bebert in forum Excel General
    Replies: 0
    Last Post: 02-26-2006, 07:15 PM
  5. Adjust the size of cells automatically
    By Dajana in forum Excel General
    Replies: 1
    Last Post: 09-06-2005, 10:05 AM

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