+ Reply to Thread
Results 1 to 9 of 9

Function to return Formula from Cell Value

  1. #1
    Registered User
    Join Date
    02-06-2013
    Location
    Oklahoma
    MS-Off Ver
    Excel 2007
    Posts
    5

    Function to return Formula from Cell Value

    I have inserted some code to extract the trend line formula (J40) from a graph and then have it separated out in the adjacent columns with a series of formulas. In cell N40 I have my formula to calculate the forecast for the 6th period for a logarithmic trend line.

    I want to avoid anymore VBA and do not want to have a manual find and replace to the first values in column M to insert an equals sign to calculate the forecast as I know this would work.
    I am looking for a function or a formula so that this formula will automatically re-calculate if the numbers in the graph change.

    Below is formulas I have and one I am needing. Attached is an image of output so far.

    K40 = LEFT(J40,LEN(J40)-10
    L40 = REPLACE(K40,FIND("ln(x) + ",K40,1),8,"*ln(L39)+")
    M40 = SUBSTITUTE(L40,",","")
    N40 = REPLACE(M40,1,4,"")
    O40 = ???

    Capture.JPG
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Function to return Formula from Cell Value

    Seems like there should be a much easier way to go about this. Can you post a cleaned version of the excel file so we can see what you're trying to accomplish within the context of the data you have available?

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

    Re: Function to return Formula from Cell Value

    I would use the LINEST() function to perform the regression directly in the spreadsheet, then the cell that calculates the forecast values can refer to the LINEST() output.

    http://office.microsoft.com/en-us/ex...in=HA010277524

    You will want to make the following "linear" connection:
    your equation : y=A*ln(x)+B
    let u=ln(x) and substitute: y=A*u+B <--- you should be able to recognize that this is a linear function in u. Your known_x argument in the LINEST() function will need to perform this substitution in one way or another.
    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-06-2013
    Location
    Oklahoma
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Function to return Formula from Cell Value

    See attached for a cleaned up version.

    You may be right, but I am going to have to have a work tab for this project anyways so doesn't matter if its too dirty but open to suggestions. Just has to update automatically after running ctrl + l macro which updates the logarithmic trendline formula based on the data from above.

    In this case I am looking for more than a linear forecast. Will be needing to use polynomial, logartihmic, etc and this is only way I know to extract necessary formula. Linest restricts me to just linear.
    Attached Files Attached Files

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

    Re: Function to return Formula from Cell Value

    In this case I am looking for more than a linear forecast. Will be needing to use polynomial, logartihmic, etc and this is only way I know to extract necessary formula. Linest restricts me to just linear.
    It takes some "upper level" math to get the formal definitions and proof of exactly what consititutes a "linear" function. Suffice it to say that every one of the the available chart trendlines is or can be transformed into a "linear" equation -- and can therefore be regressed using LINEST()

    examples:
    polynomial: y=a+bx+cx^2+dx^3...
    let u=x^2, v=x^3,... and substitute: y=a+bx+cu+dv... -- a multivariable linear regression (LINEST() help file has an example of a multivariable regression).

    exponential: y=A*exp(Bx)
    take log of both sides: ln(y)=ln(A) + x*B
    make substitutions, if needed to see: u=ln(y), k=ln(A) -> u=k+Bx -- another linear function.

    I still stand by my advice: linearize your desired regression equations, then perform the regressions directly in the spreadsheet using LINEST().

  6. #6
    Registered User
    Join Date
    02-06-2013
    Location
    Oklahoma
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Function to return Formula from Cell Value

    Thanks but this still does not answer my initial question.

    I am not a pro in statistics hence why I developed this easy workaround that lets me plug no forecast period into the exact formula excel has came up with.

    Just needing to figure out if there is a function or formula I can use in cell F21 to actually take the formula from E21 and solve it without any extra vba and/or manual manipulation.

  7. #7
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Function to return Formula from Cell Value

    I broke out the components of your equations (manually typed the numbers into the cells around the equation cell) and included an "=indirect" reference to L39. However, L39 was blank, so I just typed in a random number. If there's a number in L39, the calculation will complete. I didn't spend enough time to figure out where the different numbers were coming from, but can definitely create a few other formulas to extract the components of the equation i manually entered. If that's something you can't do.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Function to return Formula from Cell Value

    If the last post solves your question, please mark the thread as "Solved".

  9. #9
    Registered User
    Join Date
    02-06-2013
    Location
    Oklahoma
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Function to return Formula from Cell Value

    I think that is what I need to do, break it down a little more. Thanks hoya.

+ 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. formula to return blank cell - IF function
    By n1kk1 in forum Excel General
    Replies: 3
    Last Post: 12-17-2009, 08:14 AM
  2. function CELL() to return the formula in the referenced cell
    By Streep in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  3. [SOLVED] function CELL() to return the formula in the referenced cell
    By Streep in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  4. function CELL() to return the formula in the referenced cell
    By Streep in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  5. [SOLVED] function CELL() to return the formula in the referenced cell
    By Streep in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-20-2005, 06:05 PM

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