The linest function returns both the intercept and slope and other. The only solution if the LINEST function cannot work on rows is to use VBA and make it loop through the data put transpose my x, transpose my Y and store in temp in an array. Excel uses the method of least squares to return a slope and y-intercept for the. It is not possible to rearrange the data to columnar data in the sheet itself. Now my question is, is there a way to get a 2nd order fit using excel formulas using the row data as an array instead of column data? The strange thing is that if I rearrange the data so that I can have I have my X and Y in a different column it does work (formula: =LINEST(AS19:AS23 AR19:AR23^) The formula I’m using and is not working (returning #value) : The spreadsheet has been build so that on every row, there is data from 1 sample. I found that I can use the LINEST function in excel but somehow it does not work for me. The project is getting bigger and bigger and I want to automate this task. Normally I did this with a graph, get the fit and was able to calculate the X and Y for the maximum. From this fit I need to get the x,y that corresponds to its maximum. For each type of equation, the spreadsheet again uses the Excel function LINEST to find the best-fitting straight line through the data the important. For a project I need to fit a 2nd order polynomial (ax^2+bx+c) on a lot of data.