+ Reply to Thread
Results 1 to 10 of 10

Passing cell references from a cell's text to LINEST function and a graph

  1. #1
    Registered User
    Join Date
    03-02-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Passing cell references from a cell's text to LINEST function and a graph

    Hi guys,

    I'm using Excel 2003 and I'm trying to make my LINEST function and the source cells for a scatter graph use the cell range specified in another cell in the document. I figured out that it was simple to do the following:

    I250 contains: 10, shows: 10
    I251 contains: ="I"&I250, shows I10

    But I can't figure out how to do this in a larger function. I've tried a few things but none of them work. Here is an example where I want it to do a LINEST with y values in cells Ja - Jb and x values in cells Ia - Ib (where a and b are integers specified in cells I250 and J250 respectively):

    Please Login or Register  to view this content.
    I figured that maybe it isn't taking "J"&I250 as text and is interpreting it as a direct cell reference, which is why it is failing. If this is true then it might be easy to fix but I don't know how to specifiy a data type as text in Excel.

    Oh by the way, this machine is set up to use , as a decimal separator and ; in place of , for separating variables. It's annoying but it's necessary because of another piece of software we use.

    Any help appreciated!
    Last edited by DragonQ; 03-03-2009 at 07:17 AM.

  2. #2
    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: Passing cell references from a cell's text to LINEST function and a graph

    You could do something like this:

    =LINEST(INDIRECT("J" & I250 & ":J" & J250), INDIRECT("I" & I250 & ":J" & J250), TRUE, TRUE)

    However, the x and y ranges overlap.

    I251 contains: ="I"&I250, shows I10
    I251 isn't referenced.

    Using INDIRECTmakes the formula volatile, which means it recalculates whenever anything recalculates. I'd use instead dynamic named ranges, so you could just do

    =LINEST(y, x, True, True)
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-02-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Passing cell references from a cell's text to LINEST function and a graph

    =LINEST(INDIRECT("J" & I250 & ":J" & J250), INDIRECT("I" & I250 & ":J" & J250), TRUE, TRUE)
    Thanks, this code works for the LINEST cell with a slight fix:

    =LINEST(INDIRECT("J" & I250 & ":J" & J250), INDIRECT("I" & I250 & ":I" & J250), TRUE, TRUE)
    I made that error in my first post, sorry. However, I can't get the graph source to accept this code for the x values:

    Please Login or Register  to view this content.
    Any ideas?


    I251 isn't referenced.
    Yeah, that cell is just an example of how I got the simple form of the code to work.

    Using INDIRECT makes the formula volatile, which means it recalculates whenever anything recalculates. I'd use instead dynamic named ranges, so you could just do

    =LINEST(y, x, True, True)
    I guess this would be a problem for massive spreadsheets but this is just one sheet of <300 rows and <10 columns so I'm not worried about it recalculating any time anything changes. It's just far easier than going into both the LINEST cell and the graph properties, finding the cell references and changing them manually.

  4. #4
    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: Passing cell references from a cell's text to LINEST function and a graph

    I can't get the graph source to accept this code for the x values:

    =INDIRECT("J" & J249 & ":J" & J250)
    Bring up the formula auditing toolbar and watch it evaluate.

  5. #5
    Registered User
    Join Date
    03-02-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Passing cell references from a cell's text to LINEST function and a graph

    It gets to:

    Please Login or Register  to view this content.
    and then fails :/. I thought not using INDIRECT made more sense in this case but that doesn't work either. This works:

    Please Login or Register  to view this content.
    but then this doesn't:

    Please Login or Register  to view this content.
    Last edited by DragonQ; 03-02-2009 at 12:01 PM.

  6. #6
    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: Passing cell references from a cell's text to LINEST function and a graph

    Dunno. Post a workbook.

  7. #7
    Registered User
    Join Date
    03-02-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Passing cell references from a cell's text to LINEST function and a graph

    I just tried editing the series formula from this:

    =SERIES(;Sheet1!$I$9:$I$100;Sheet1!$J$9:$J$100;2)

    to this:

    =SERIES(;Sheet1!XRange;Sheet1!YRange;2)

    with the dynamic variables currently evaluating as:

    XRange = $I$9:$I$100
    YRange = $J$9:$J$100

    and it still doesn't work (error is about one or more invalid references).


    I have attached a spreadsheet with sample data and the relevent graph, dynamic variables, etc.
    Attached Files Attached Files

  8. #8
    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: Passing cell references from a cell's text to LINEST function and a graph

    This started as a question about LINEST. Is that solved?

  9. #9
    Registered User
    Join Date
    03-02-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Passing cell references from a cell's text to LINEST function and a graph

    The LINEST function works, yes. But the question was:
    Passing cell references from a cell's text to LINEST function and a graph

  10. #10
    Registered User
    Join Date
    03-02-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Passing cell references from a cell's text to LINEST function and a graph

    Woo, got it working using the OFFSET function (apparently just using INDIRECT doesn't work for graphs...). I made some dynamic variables for the x values (XRange):

    Please Login or Register  to view this content.
    And the y values (YRange):

    Please Login or Register  to view this content.
    And then just put =Sheet1!XRange for the source of the x values for the graph series and then =Sheet1!YRange for the y values.

    In this case, Sheet1!$J$249 contains my starting cell row reference and Sheet1!$J$250 contains my ending cell row reference. So if I want the series' x values to be taken from cells I15 to I100 for example, I just put 15 in cell J249 and 100 in cell J250. Obviously you can make the columns dynamic too but in this case I didn't need to.

    Thanks for the assistance!
    Last edited by DragonQ; 03-03-2009 at 07:50 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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