SOLVED

Formula changes when a row is inserted

%3CLINGO-SUB%20id%3D%22lingo-sub-3089039%22%20slang%3D%22en-US%22%3EFormula%20changes%20when%20a%20row%20is%20inserted%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3089039%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20I%20insert%20a%20row%20anywhere%2C%20but%20normally%20between%20row%202%20and%20row%203%20to%20add%20a%20new%20row%20to%20fill%20to%20keep%20the%20most%20current%20first.%20This%20formula%20which%20should%20be%20as%20shown%3A%3C%2FP%3E%3CP%3E%3DSUMPRODUCT(%24F%242%3A%24F%2449*(INT(%24A%242%3A%24A%2449)%3DA6))%2C%20the%20inserted%20row%20changes%20the%20%242%20to%20%241%20in%20both%20places.%20It%20used%20to%20work%20OK%20as%20long%20as%20I%20left%20a%20dummy%20row%20as%20row%202.%20But%20not%20now%20after%20I%20inadvertently%20deleted%20dummy%20row%202%20it%20stopped%20working%20correctly.%26nbsp%3B%20How%20can%20I%20get%20this%20to%20insert%20and%20keep%20the%20formula%20as%20shown.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20formula%20is%20in%20Sheet%20is%20Q1%2C%20Column%20J.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3089039%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-3089071%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20changes%20when%20a%20row%20is%20inserted%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3089071%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F321448%22%20target%3D%22_blank%22%3E%40wcstarks%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EChange%20the%20formula%20in%20J2%20to%3C%2FP%3E%0A%3CP%3E%3DSUMPRODUCT(%5BCarbs%5D*(%5BDate%5D%3D%5B%40Date%5D))%3C%2FP%3E%0A%3CP%3Eor%20better%2C%20to%3C%2FP%3E%0A%3CP%3E%3DSUMIF(%5BDate%5D%2C%5B%40Date%5D%2C%5BCarbs%5D)%3C%2FP%3E%0A%3CP%3Eand%20fill%20down.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3089270%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20changes%20when%20a%20row%20is%20inserted%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3089270%22%20slang%3D%22en-US%22%3E%3CP%3EI%20just%20replaced%20my%20formula%20with%20your%20second%20formula%20and%20attempted%20to%20insert%20a%20row%2C%20and%20it%20produced%20the%20original%20erroneous%20formula%3A%20%3DSUMPRODUCT(%24F%241%3A%24F%2451*(INT(%24A%241%3A%24A%2451)%3DA4))%20Somehow%2C%20Excel%20has%20this%20formula%20in%20memory%20and%20uses%20it%20instead%20of%20the%20formula%20in%20the%20column.%20So%2C%20I%20guess%20the%20real%20issue%20is%20how%20to%20get%20Excel%20to%20forget%20this%20erroneous%20formula%20when%20inserting%20a%20new%20row%20and%20use%20the%20current%20formula%20for%20that%20column.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20notice%20that%20I%20get%20a%20notification%20of%20an%20inconsistent%20formula%2C%20even%20though%20the%20formula%20is%20the%20same%20in%20each%20row.%20Excel%20must%20be%20comparing%20the%20new%20formula%20with%20the%20one%20it%20has%20in%20memory.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3089288%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20changes%20when%20a%20row%20is%20inserted%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3089288%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F321448%22%20target%3D%22_blank%22%3E%40wcstarks%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20data%20are%20formatted%20as%20a%20table%2C%20you%20can%20use%20so-called%20structured%20references.%3C%2FP%3E%0A%3CP%3EIn%20a%20formula%20in%20the%20table%20itself%2C%20you%20can%20refer%20to%20all%20data%20rows%20in%20a%20column%20as%20%5BColumnName%5D.%3C%2FP%3E%0A%3CP%3EFor%20example%20%5BDate%5D%20refers%20to%20A2%3AA49%2C%20but%20if%20you%20insert%20a%20row%20in%20the%20table%2C%20%5BDate%5D%20will%20refer%20to%20A2%3AA50.%3C%2FP%3E%0A%3CP%3EAnd%20you%20can%20use%20%5B%40ColumnName%5D%20to%20refer%20to%20the%20cell%20in%20the%20specified%20column%20in%20the%20same%20row%20as%20the%20cell%20with%20the%20formula.%3C%2FP%3E%0A%3CP%3EFor%20example%20in%20J2%2C%20%5B%40Date%5D%20refers%20to%20A2%20and%20in%20J10%2C%20%5B%40Date%5D%20refers%20to%20A10.%3C%2FP%3E%0A%3CP%3ESee%20the%20attached%20version%20of%20the%20workbook.%20Try%20inserting%20a%20new%20row%20in%20the%20table.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3089337%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20changes%20when%20a%20row%20is%20inserted%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3089337%22%20slang%3D%22en-US%22%3EI%20just%20downloaded%20your%20revision%20of%20the%20book%20and%20I%20see%20it%20works%20fine.%20Why%20did%20my%20modification%20in%20my%20version%20not%20work%20correctly%2C%20while%20it%20does%20in%20your%20version%3F%3C%2FLINGO-BODY%3E
Contributor

When I insert a row anywhere, but normally between row 2 and row 3 to add a new row to fill to keep the most current first. This formula which should be as shown:

=SUMPRODUCT($F$2:$F$49*(INT($A$2:$A$49)=A6)), the inserted row changes the $2 to $1 in both places. It used to work OK as long as I left a dummy row as row 2. But not now after I inadvertently deleted dummy row 2 it stopped working correctly.  How can I get this to insert and keep the formula as shown.

 

The formula is in Sheet is Q1, Column J. The sheet is formatted as a table.

9 Replies
best response confirmed by wcstarks (Contributor)
Solution

@wcstarks 

Change the formula in J2 to

=SUMPRODUCT([Carbs]*([Date]=[@Date]))

or better, to

=SUMIF([Date],[@Date],[Carbs])

and fill down.

Thank you for your response. Would you please explain how you are able to use [carbs] in your rendering of the function to help me better understand? And please help me understand how the differing syntaxes produce similar results, that I may learn.

I just replaced my formula with your second formula and attempted to insert a row, and it produced the original erroneous formula: =SUMPRODUCT($F$1:$F$51*(INT($A$1:$A$51)=A4)) Somehow, Excel has this formula in memory and uses it instead of the formula in the column. So, I guess the real issue is how to get Excel to forget this erroneous formula when inserting a new row and use the current formula for that column.

 

I also notice that I get a notification of an inconsistent formula, even though the formula is the same in each row. Excel must be comparing the new formula with the one it has in memory.

@wcstarks 

When data are formatted as a table, you can use so-called structured references.

In a formula in the table itself, you can refer to all data rows in a column as [ColumnName].

For example [Date] refers to A2:A49, but if you insert a row in the table, [Date] will refer to A2:A50.

And you can use [@ColumnName] to refer to the cell in the specified column in the same row as the cell with the formula.

For example in J2, [@Date] refers to A2 and in J10, [@Date] refers to A10.

See the attached version of the workbook. Try inserting a new row in the table.

I just downloaded your revision of the book and I see it works fine. Why did my modification in my version not work correctly, while it does in your version?

@wcstarks 

I don't know - I'd have to see your revision of the workbook.

It is the same one I sent to you.

@wcstarks 

But the one attached to the first post in this discussion has not been modified.

I guess I don't understand. Did you not make a copy of the one I uploaded. Then it would be a copy of the one which was having the issue described. I guess it doesn't matter now. You got it working on the one you sent me. When I enter a new function or modify a function, I then select the green check mark to save the function. It usually updates the column automatically. The then that perplexes me is, it will then ask to update the column, after it is already done it. Other times I will get the message of inconsistent functions, even though I cannot see any difference from one cell to the next.