Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel formula to reference 'CELL TO THE LEFT'

I'm trying to do conditional formatting so that the cell color will change if the value is different from the value in the cell left of it (each column is a month, in each row are the expenses on certain object. I want to monitor easily changes in prices over months.)

I can do it per cell and format-drag it, but I would like a general formula to apply to the whole worksheet.

Thanks!

like image 718
mik Avatar asked Feb 03 '09 14:02

mik


People also ask

How do you reference a cell relative to a cell?

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.

How do I reference next cell in Excel?

Click the cell where you want to enter a reference to another cell. Type an equals (=) sign in the cell. Click the cell in the same worksheet you want to make a reference to, and the cell name is automatically entered after the equal sign. Press Enter to create the cell reference.


2 Answers

=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-1) 
like image 92
Jason Young Avatar answered Sep 20 '22 22:09

Jason Young


The shortest most compatible version is:

=INDIRECT("RC[-1]",0) 

"RC[-1]" means one column to the left. "R[1]C[-1]" is bottom-left.

The second parameter 0 means that the first parameter is interpreted using R1C1 notation.

The other options:

=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-1) 

Too long in my opinion. But useful if the relative value is dynamic/derived from another cell. e.g.:

=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0, A1) 

The most simple option:

= RC[-1] 

has the disadvantage that you need to turn on R1C1 notation using options, which is a no-go when other people have to use the excel.

like image 44
seb Avatar answered Sep 23 '22 22:09

seb