Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using relative positions in Excel formulas

Tags:

excel

formula

How do I create a formula that isn't made invalid when I delete a row.

For example in cell F12 I have the formula: =F11+D12-E12

This basically says take the value from the cell above then add the value of the cell 2 to the left and subtract the value in the cell directly to the left.

However, because I'm using actual cell addresses, as soon as I delete a row, all the rows below become invalid.

How do i express the formula by relative position (ie = "1 above" + "2 to left" - "1 to left")

Thanks.

like image 992
FloatLeft Avatar asked Apr 09 '11 08:04

FloatLeft


People also ask

How do you use the relative function in Excel?

By default, every cell in Excel has a relative reference. In relative references, type “=A1+A2” in cell A3, copy and paste the formula in cell B3, and the formula automatically changes to “=B1+B2.” In absolute references, the cell address does not change when the formula is copied.

When should you use relative cell references in Excel?

Relative references are especially convenient whenever you need to repeat the same calculation across multiple rows or columns.


2 Answers

You can use either

  • =OFFSET(F12,-1,0)+OFFSET(F12,0,-2)-OFFSET(F12,0,-1), or
  • =INDIRECT("F11",true)+INDIRECT("D12",true)-INDIRECT("E12",true)
  • =INDIRECT("R11C6",false)+INDIRECT("R12C4",false)-INDIRECT("R12C5",false)
  • =INDIRECT("R[-1]",false)+INDIRECT("C[-2]",false)-INDIRECT("C[-1]",false)

Both functions also allow to specify ranges, just use whatever has your personal preference (see Excel Help)…

like image 190
mousio Avatar answered Sep 21 '22 10:09

mousio


  • You can switch e.g. to the R1C1 reference style (excel options)
  • Use OFFSET function (e.g. =OFFSET(F12;-1;0) for above)
like image 42
Howard Avatar answered Sep 20 '22 10:09

Howard