There are three ways, at least, to get the best linear fit to data. You can use the functions SLOPE and INTERCEPT in separate cells. These functions have the form
- Code: Select all Expand viewCollapse view
=SLOPE(YRange;XRange)
=INTERCEPT(YRange;XRange)
You can also use the RSQ() function to get the R^2 of the fit.
You can use the array function LINEST() to get the linear fit. It returns various statistics in addition to the slope and intercept. I suggest you check out the Help section, as that function is more complicated.
Finally, if the data are used in a scatter chart, you can double click on the chart to put it in edit mode and then go to Insert -> Trend Lines to add the line, equation and R Squared to the chart.