SOLVED

Formula choosing next cells inconsistently

%3CLINGO-SUB%20id%3D%22lingo-sub-2762744%22%20slang%3D%22en-US%22%3EFormula%20choosing%20next%20cells%20inconsistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2762744%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20a%20formula%20in%20a%20column%20that%20increases%20with%20each%20row.%3C%2FP%3E%3CP%3E%3DIF(C10%26gt%3B0%2CC10-C9%2C0)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20correctly%20becomes%26nbsp%3B%3DIF(C11%26gt%3B0%2CC11-C10%2C0)%20in%20a%20row%20added%20at%20the%20bottom%20of%20the%20spreadsheet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20when%20I%20add%20a%20new%20row%20to%20the%20bottom%2C%20the%20formula%20in%20the%20row%20above%20the%20new%20one%20changes%20from%20a%20correct%20formula%20to%20an%20incorrect%20one.%20It%20becomes%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(C10%26gt%3B0%2CC10-C8%2C0)%26nbsp%3B%20%26nbsp%3B%5Bthe%20subtraction%20C10-C8%20is%202%20lines%20apart%2C%20instead%20of%201%5D%3C%2FP%3E%3CP%3EIt%20was%26nbsp%3B%3DIF(C10%26gt%3B0%2CC10-C9%2C0)%20%5Bcorrect%5D%20before%20I%20added%20the%20new%20ottom%20row%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2762744%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2762761%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20choosing%20next%20cells%20inconsistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2762761%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1159669%22%20target%3D%22_blank%22%3E%40Ned_O%3C%2FA%3E%26nbsp%3BYou%20would%20need%20a%20formula%20with%20OFFSET%2C%20like%20this%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DIF(C10%26gt%3B0%2CC10-OFFSET(C10%2C-1%2C0)%2C0)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2762789%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20choosing%20next%20cells%20inconsistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2762789%22%20slang%3D%22en-US%22%3EThanks.%20That%20seems%20to%20be%20working.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2763001%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20choosing%20next%20cells%20inconsistently%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2763001%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1159669%22%20target%3D%22_blank%22%3E%40Ned_O%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnother%20variant%20you%20may%20add%20named%20formula%20(reference).%20If%20you%20stay%2C%20for%20example%2C%20on%20C10%2C%20define%20it%20as%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20304px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F311248i0784636E5ADFF10E%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EBe%20sure%20to%20use%20absolute%20reference%20for%20column%20and%20relative%20one%20for%20row.%3C%2FP%3E%0A%3CP%3EWith%20that%20formula%20could%20be%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D(C11-CellUp)*(C11%20%26gt%3B%200)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I am using a formula in a column that increases with each row.

=IF(C10>0,C10-C9,0)

 

It correctly becomes =IF(C11>0,C11-C10,0) in a row added at the bottom of the spreadsheet.

 

However, when I add a new row to the bottom, the formula in the row above the new one changes from a correct formula to an incorrect one. It becomes  

=IF(C10>0,C10-C8,0)   [the subtraction C10-C8 is 2 lines apart, instead of 1]

It was =IF(C10>0,C10-C9,0) [correct] before I added the new ottom row

7 Replies

@Ned_O You would need a formula with OFFSET, like this:

=IF(C10>0,C10-OFFSET(C10,-1,0),0)

 

Well. actually that seems to have stopped working. 

This was supposed to be a simple mileage tracker (for use on my cell when in the car). The idea was that I would only have to add the ending mileage (Column "C"), rather than start and stop, etc., and that mileage would be calculated in column "I".

 

It works except when I add more than 1 line. See highlighted cell "I51". It had the correct formula: =IF(C52>0, C52-OFFSET(C52,-1,0)0)

But when I added the next line (52) that ends up with the correct formula in I52, but I51 ends up converting to the same formula. I'm not sure why.

 

Any ideas?

Thanks, Ned

best response confirmed by Ned_O (Occasional Contributor)
Solution

@Ned_O 

Another variant you may add named formula (reference). If you stay, for example, on C10, define it as

image.png

Be sure to use absolute reference for column and relative one for row.

With that formula could be

=(C11-CellUp)*(C11 > 0)
Would "Cell Up" change to the appropriate cell when a row is added? Ned

@Ned_O 

If you stay on any cell (or enter formula into any cell), CellUp returns value from the cell above. Doesn't matter where current cell is and how you change it's location, by adding rows or by other way.

Thanks, Sergei. After working through a few other issues like" inserting rows with the formulas in place" and updating the formulas in a column, I did get to work the "CELLUP" to work.
Thanks again. ned

@Ned_O , great, glad to help